Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic possibly due to x/sys version #1285

Closed
Meowzz95 opened this issue Sep 17, 2021 · 4 comments
Closed

Panic possibly due to x/sys version #1285

Meowzz95 opened this issue Sep 17, 2021 · 4 comments

Comments

@Meowzz95
Copy link

When I log using the default logger (logrus.Infof) in go test, some combination of logrus and other lib/code triggers panic.

I'm unable to reproduce this using a clean project but I can share my stack trace and library used.

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff20525c9e]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff20525c9e
stack: frame={sp:0x7ffeefbff348, fp:0x7ffeefbff398} stack=[0x7ffeefb803e8,0x7ffeefbff450)
0x00007ffeefbff248:  0x01007ffeefbff268  0x0000000000000004 
0x00007ffeefbff258:  0x000000000000001f  0x00007fff20525c9e 
0x00007ffeefbff268:  0x0b01dfacedebac1e  0x0000000000000001 
0x00007ffeefbff278:  0x0000000004038eb1 <runtime.throw+0x0000000000000071>  0x00007ffeefbff318 
0x00007ffeefbff288:  0x000000000444f4c3  0x00007ffeefbff2d0 
0x00007ffeefbff298:  0x0000000004039168 <runtime.fatalthrow.func1+0x0000000000000048>  0x00000000046c91c0 
0x00007ffeefbff2a8:  0x0000000000000001  0x0000000000000001 
0x00007ffeefbff2b8:  0x00007ffeefbff318  0x0000000004038eb1 <runtime.throw+0x0000000000000071> 
0x00007ffeefbff2c8:  0x00000000046c91c0  0x00007ffeefbff308 
0x00007ffeefbff2d8:  0x00000000040390f0 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff2e8 
0x00007ffeefbff2e8:  0x0000000004039120 <runtime.fatalthrow.func1+0x0000000000000000>  0x00000000046c91c0 
0x00007ffeefbff2f8:  0x0000000004038eb1 <runtime.throw+0x0000000000000071>  0x00007ffeefbff318 
0x00007ffeefbff308:  0x00007ffeefbff338  0x0000000004038eb1 <runtime.throw+0x0000000000000071> 
0x00007ffeefbff318:  0x00007ffeefbff320  0x0000000004038ee0 <runtime.throw.func1+0x0000000000000000> 
0x00007ffeefbff328:  0x0000000004454816  0x000000000000002a 
0x00007ffeefbff338:  0x00007ffeefbff388  0x000000000404f116 <runtime.sigpanic+0x0000000000000396> 
0x00007ffeefbff348: <0x0000000004454816  0x00000000046075a0 
0x00007ffeefbff358:  0x00007ffeefbff3c8  0x000000000402a106 <runtime.(*mheap).allocSpan+0x0000000000000546> 
0x00007ffeefbff368:  0x000000c00024a000  0x0000000000002000 
0x00007ffeefbff378:  0x000000c000000008  0x0000000000000000 
0x00007ffeefbff388:  0x00007ffeefbff3d0 !0x00007fff20525c9e 
0x00007ffeefbff398: >0x00007ffeefbff3d0  0x000000000466c000 
0x00007ffeefbff3a8:  0x0000000000000517  0x00000000041560e5 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005> 
0x00007ffeefbff3b8:  0x000000000406d6ff <runtime.syscall+0x000000000000001f>  0x000000c00004e5e8 
0x00007ffeefbff3c8:  0x00007ffeefbff410  0x000000c00004e5b8 
0x00007ffeefbff3d8:  0x000000000406b550 <runtime.asmcgocall+0x0000000000000070>  0x0000000000000001 
0x00007ffeefbff3e8:  0x0000000004014000 <runtime.evacuate+0x0000000000000380>  0x4000000000001018 
0x00007ffeefbff3f8:  0x0000000000000000  0x00000000046fe2d8 
0x00007ffeefbff408:  0x0000000000000a70  0x000000c000105d40 
0x00007ffeefbff418:  0x0000000004069669 <runtime.systemstack+0x0000000000000049>  0x0000000000000004 
0x00007ffeefbff428:  0x00000000044aa440  0x00000000046c91c0 
0x00007ffeefbff438:  0x00007ffeefbff480  0x0000000004069565 <runtime.mstart+0x0000000000000005> 
0x00007ffeefbff448:  0x000000000406951d <runtime.rt0_go+0x000000000000013d> 
runtime.throw({0x4454816, 0x46075a0})
	/usr/local/go/src/runtime/panic.go:1198 +0x71
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff20525c9e
stack: frame={sp:0x7ffeefbff348, fp:0x7ffeefbff398} stack=[0x7ffeefb803e8,0x7ffeefbff450)
0x00007ffeefbff248:  0x01007ffeefbff268  0x0000000000000004 
0x00007ffeefbff258:  0x000000000000001f  0x00007fff20525c9e 
0x00007ffeefbff268:  0x0b01dfacedebac1e  0x0000000000000001 
0x00007ffeefbff278:  0x0000000004038eb1 <runtime.throw+0x0000000000000071>  0x00007ffeefbff318 
0x00007ffeefbff288:  0x000000000444f4c3  0x00007ffeefbff2d0 
0x00007ffeefbff298:  0x0000000004039168 <runtime.fatalthrow.func1+0x0000000000000048>  0x00000000046c91c0 
0x00007ffeefbff2a8:  0x0000000000000001  0x0000000000000001 
0x00007ffeefbff2b8:  0x00007ffeefbff318  0x0000000004038eb1 <runtime.throw+0x0000000000000071> 
0x00007ffeefbff2c8:  0x00000000046c91c0  0x00007ffeefbff308 
0x00007ffeefbff2d8:  0x00000000040390f0 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff2e8 
0x00007ffeefbff2e8:  0x0000000004039120 <runtime.fatalthrow.func1+0x0000000000000000>  0x00000000046c91c0 
0x00007ffeefbff2f8:  0x0000000004038eb1 <runtime.throw+0x0000000000000071>  0x00007ffeefbff318 
0x00007ffeefbff308:  0x00007ffeefbff338  0x0000000004038eb1 <runtime.throw+0x0000000000000071> 
0x00007ffeefbff318:  0x00007ffeefbff320  0x0000000004038ee0 <runtime.throw.func1+0x0000000000000000> 
0x00007ffeefbff328:  0x0000000004454816  0x000000000000002a 
0x00007ffeefbff338:  0x00007ffeefbff388  0x000000000404f116 <runtime.sigpanic+0x0000000000000396> 
0x00007ffeefbff348: <0x0000000004454816  0x00000000046075a0 
0x00007ffeefbff358:  0x00007ffeefbff3c8  0x000000000402a106 <runtime.(*mheap).allocSpan+0x0000000000000546> 
0x00007ffeefbff368:  0x000000c00024a000  0x0000000000002000 
0x00007ffeefbff378:  0x000000c000000008  0x0000000000000000 
0x00007ffeefbff388:  0x00007ffeefbff3d0 !0x00007fff20525c9e 
0x00007ffeefbff398: >0x00007ffeefbff3d0  0x000000000466c000 
0x00007ffeefbff3a8:  0x0000000000000517  0x00000000041560e5 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005> 
0x00007ffeefbff3b8:  0x000000000406d6ff <runtime.syscall+0x000000000000001f>  0x000000c00004e5e8 
0x00007ffeefbff3c8:  0x00007ffeefbff410  0x000000c00004e5b8 
0x00007ffeefbff3d8:  0x000000000406b550 <runtime.asmcgocall+0x0000000000000070>  0x0000000000000001 
0x00007ffeefbff3e8:  0x0000000004014000 <runtime.evacuate+0x0000000000000380>  0x4000000000001018 
0x00007ffeefbff3f8:  0x0000000000000000  0x00000000046fe2d8 
0x00007ffeefbff408:  0x0000000000000a70  0x000000c000105d40 
0x00007ffeefbff418:  0x0000000004069669 <runtime.systemstack+0x0000000000000049>  0x0000000000000004 
0x00007ffeefbff428:  0x00000000044aa440  0x00000000046c91c0 
0x00007ffeefbff438:  0x00007ffeefbff480  0x0000000004069565 <runtime.mstart+0x0000000000000005> 
0x00007ffeefbff448:  0x000000000406951d <runtime.rt0_go+0x000000000000013d> 
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:719 +0x396

goroutine 35 [syscall]:
syscall.syscall(0x41560e0, 0x2, 0x40487413, 0xc00004e678)
	/usr/local/go/src/runtime/sys_darwin.go:22 +0x3b fp=0xc00004e5e8 sp=0xc00004e5c8 pc=0x406819b
syscall.syscall(0x4016825, 0xc0001140c0, 0xc0001140c0, 0xc000123210)
	<autogenerated>:1 +0x26 fp=0xc00004e630 sp=0xc00004e5e8 pc=0x406dec6
golang.org/x/sys/unix.ioctl(0xd3b2146fe4514b4a, 0x1, 0xc00004e690)
	/Users/mimimi/go/pkg/mod/golang.org/x/sys@v0.0.0-20210403161142-5e06dd20ab57/unix/zsyscall_darwin_amd64.go:690 +0x39 fp=0xc00004e660 sp=0xc00004e630 pc=0x4155d79
golang.org/x/sys/unix.IoctlGetTermios(...)
	/Users/mimimi/go/pkg/mod/golang.org/x/sys@v0.0.0-20210403161142-5e06dd20ab57/unix/ioctl.go:73
github.com/sirupsen/logrus.isTerminal(0x400)
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/terminal_check_bsd.go:11 +0x50 fp=0xc00004e6d0 sp=0xc00004e660 pc=0x415c7f0
github.com/sirupsen/logrus.checkIfTerminal({0x44ae8a0, 0xc00011a010})
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/terminal_check_notappengine.go:13 +0x75 fp=0xc00004e6e8 sp=0xc00004e6d0 pc=0x415c895
github.com/sirupsen/logrus.(*TextFormatter).init(0xc0001eed20, 0x4f93648)
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/text_formatter.go:106 +0x34 fp=0xc00004e768 sp=0xc00004e6e8 pc=0x415c974
github.com/sirupsen/logrus.(*TextFormatter).Format.func1()
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/text_formatter.go:196 +0x25 fp=0xc00004e788 sp=0xc00004e768 pc=0x415e025
sync.(*Once).doSlow(0x44b37c8, 0xc000132af8)
	/usr/local/go/src/sync/once.go:68 +0xd2 fp=0xc00004e7f0 sp=0xc00004e788 pc=0x4074172
sync.(*Once).Do(...)
	/usr/local/go/src/sync/once.go:59
github.com/sirupsen/logrus.(*TextFormatter).Format(0xc0001eed20, 0xc0002384d0)
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/text_formatter.go:196 +0xebe fp=0xc00004ed60 sp=0xc00004e7f0 pc=0x415d9de
github.com/sirupsen/logrus.(*Entry).write(0xc0002384d0)
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:279 +0x56 fp=0xc00004edf0 sp=0xc00004ed60 pc=0x4157cb6
github.com/sirupsen/logrus.(*Entry).log(0xc0002466b8, 0x4, {0xc0002189a4, 0x4})
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:251 +0x219 fp=0xc00004ee60 sp=0xc00004edf0 pc=0x41578b9
github.com/sirupsen/logrus.(*Entry).Log(0xc000238460, 0x4, {0xc0002466b8, 0x0, 0x0})
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:293 +0x4f fp=0xc00004ee90 sp=0xc00004ee60 pc=0x4157f0f
github.com/sirupsen/logrus.(*Entry).Logf(0xc000238460, 0x4, {0x4444f10, 0xc000246720}, {0x0, 0x24, 0x474})
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/entry.go:338 +0x85 fp=0xc00004eed8 sp=0xc00004ee90 pc=0x4158465
github.com/sirupsen/logrus.(*Logger).Logf(0xc000207dc0, 0x4, {0x4444f10, 0x4}, {0x0, 0x0, 0x0})
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:151 +0x85 fp=0xc00004ef28 sp=0xc00004eed8 pc=0x415a425
github.com/sirupsen/logrus.(*Logger).Infof(...)
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:165
github.com/sirupsen/logrus.Infof(...)
	/Users/mimimi/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/exported.go:199
XXX/services.TestXXXService(0x0)
	/Users/mimimi/go/src/XXX/services/XXXService_test.go:98 +0x3a fp=0xc00004ef70 sp=0xc00004ef28 pc=0x42a47da
testing.tRunner(0xc000105ba0, 0x44613f0)
	/usr/local/go/src/testing/testing.go:1259 +0x102 fp=0xc00004efc0 sp=0xc00004ef70 pc=0x40f5182
testing.(*T).Run·dwrap·21()
	/usr/local/go/src/testing/testing.go:1306 +0x2a fp=0xc00004efe0 sp=0xc00004efc0 pc=0x40f5e8a
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc00004efe8 sp=0xc00004efe0 pc=0x406b841
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:1306 +0x35a

goroutine 1 [chan receive]:
testing.(*T).Run(0xc000105a00, {0x4449226, 0x664e0ae033c9}, 0x44613f0)
	/usr/local/go/src/testing/testing.go:1307 +0x375
testing.runTests.func1(0xc00022c9f0)
	/usr/local/go/src/testing/testing.go:1598 +0x6e
testing.tRunner(0xc000105a00, 0xc000161d18)
	/usr/local/go/src/testing/testing.go:1259 +0x102
testing.runTests(0xc000152400, {0x46b9940, 0x1, 0x1}, {0x40866ed, 0x444819c, 0x0})
	/usr/local/go/src/testing/testing.go:1596 +0x43f
testing.(*M).Run(0xc000152400)
	/usr/local/go/src/testing/testing.go:1504 +0x51d
main.main()
	_testmain.go:43 +0x14b

Library used:

go 1.17

require (
	github.com/labstack/echo/v4 v4.5.0
	github.com/sirupsen/logrus v1.8.1
	github.com/stretchr/testify v1.7.0
	gorm.io/driver/mysql v1.1.2
	gorm.io/driver/sqlite v1.1.5
	gorm.io/gorm v1.21.15
)

require (
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/go-sql-driver/mysql v1.6.0 // indirect
	github.com/jinzhu/inflection v1.0.0 // indirect
	github.com/jinzhu/now v1.1.2 // indirect
	github.com/labstack/gommon v0.3.0 // indirect
	github.com/mattn/go-colorable v0.1.8 // indirect
	github.com/mattn/go-isatty v0.0.12 // indirect
	github.com/mattn/go-sqlite3 v1.14.8 // indirect
	github.com/pmezard/go-difflib v1.0.0 // indirect
	github.com/valyala/bytebufferpool v1.0.0 // indirect
	github.com/valyala/fasttemplate v1.2.1 // indirect
	golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
	golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
	golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect
	golang.org/x/text v0.3.6 // indirect
	gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)

This happens every time I run the test, even the log call is the first line of code in a test method like

func TestXXX(t *testing.T) {
	logrus.Infof("test") //panic
	suite.Run(t, new(XXX))
}

I searched and found this might be related golang/go#46763

@AlexanderYastrebov
Copy link

I think it is a duplicate of #1275

I'm unable to reproduce this using a clean project

I think go get -u github.com/sirupsen/logrus should update golang.org/x/sys

@Meowzz95
Copy link
Author

Yea, I think I did some package upgrade and the error was mysteriously gone. The part where I don't understand is, I only created this project days ago, and freshly installed logrus, why it wasn't using the latest version of x/sys back then?

@AlexanderYastrebov
Copy link

created this project days ago

#1280 was merged on 2021-09-11T12:20:32Z (just 8 days ago)

@Meowzz95
Copy link
Author

I guess that's it!
Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants