Go Unit Test Crashes with logrus

409 views
Skip to first unread message

Yoram Forscher

unread,
Sep 23, 2021, 2:23:45 PM9/23/21
to golang-nuts

I have a problem running Go unit tests on my laptop. When I run the test it crashes with SIGSEGV inside logrus. If I set the logging level to a high level (e.g., FatalLevel), disabling actual logging, it does not crash.

I tried to delete and download logrus again to no avail.

I'm running with Go 1.17.1 (it happens with 1.17 also) and logrus v1.7.0. My laptop runs macOS Catalina version 10.15.7

Thanks in advance for any help with this issue.

I'm attaching the code as well as the crash:

package util

import (
  "github.com/sirupsen/logrus"
  "testing"
)

var logger = logrus.New()

func TestSomething(t *testing.T) {
  logger.Level = logrus.InfoLevel
  logger.Info("Tested")
}


=== RUN   TestSomething

fatal error: unexpected signal during runtime execution

[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff672e870a]


runtime stack:

runtime: unexpected return pc for runtime.sigpanic called from 0x7fff672e870a

stack: frame={sp:0x7ffeefbff698, fp:0x7ffeefbff6e8} stack=[0x7ffeefb80738,0x7ffeefbff7a0)

0x00007ffeefbff598:  0x01007ffeefbff5b8  0x0000000000000004 

0x00007ffeefbff5a8:  0x000000000000001f  0x00007fff672e870a 

0x00007ffeefbff5b8:  0x0b01dfacedebac1e  0x0000000000000001 

0x00007ffeefbff5c8:  0x0000000004039b11 <runtime.throw+0x0000000000000071>  0x00007ffeefbff668 

0x00007ffeefbff5d8:  0x00000000041b2eb6  0x00007ffeefbff620 

0x00007ffeefbff5e8:  0x0000000004039dc8 <runtime.fatalthrow.func1+0x0000000000000048>  0x00000000043059c0 

0x00007ffeefbff5f8:  0x0000000000000001  0x0000000000000001 

0x00007ffeefbff608:  0x00007ffeefbff668  0x0000000004039b11 <runtime.throw+0x0000000000000071> 

0x00007ffeefbff618:  0x00000000043059c0  0x00007ffeefbff658 

0x00007ffeefbff628:  0x0000000004039d50 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff638 

0x00007ffeefbff638:  0x0000000004039d80 <runtime.fatalthrow.func1+0x0000000000000000>  0x00000000043059c0 

0x00007ffeefbff648:  0x0000000004039b11 <runtime.throw+0x0000000000000071>  0x00007ffeefbff668 

0x00007ffeefbff658:  0x00007ffeefbff688  0x0000000004039b11 <runtime.throw+0x0000000000000071> 

0x00007ffeefbff668:  0x00007ffeefbff670  0x0000000004039b40 <runtime.throw.func1+0x0000000000000000> 

0x00007ffeefbff678:  0x00000000041b5e63  0x000000000000002a 

0x00007ffeefbff688:  0x00007ffeefbff6d8  0x000000000404fd76 <runtime.sigpanic+0x0000000000000396> 

0x00007ffeefbff698: <0x00000000041b5e63  0x00000000042af028 

0x00007ffeefbff6a8:  0x00000000042d4ec0  0x00000000040c040a <testing.(*T).Run·dwrap·21+0x000000000000002a> 

0x00007ffeefbff6b8:  0x000000c0001943b0  0x0000000004011d5e <runtime.mallocgc+0x000000000000065e> 

0x00007ffeefbff6c8:  0x000000c00018a680  0x0000000000000000 

0x00007ffeefbff6d8:  0x00007ffeefbff720 !0x00007fff672e870a 

0x00007ffeefbff6e8: >0x00007ffeefbff720  0x00000000042cc000 

0x00007ffeefbff6f8:  0x0000000000000920  0x00000000040f99e5 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005

0x00007ffeefbff708:  0x000000000406d5ff <runtime.syscall+0x000000000000001f>  0x000000c000054578 

0x00007ffeefbff718:  0x000000000406cf6c <runtime.nanotime_trampoline+0x000000000000000c>  0x000000c000054548 

0x00007ffeefbff728:  0x000000000406b450 <runtime.asmcgocall+0x0000000000000070>  0x0000000000000002 

0x00007ffeefbff738:  0x000000c000194758  0x0000000000000001 

0x00007ffeefbff748:  0x0000000000000000  0x000000c0000001a0 

0x00007ffeefbff758:  0x0000000000000ae0  0x000000c00018a680 

0x00007ffeefbff768:  0x000000000406964b <runtime.morestack+0x000000000000008b>  0x0000000000000004 

0x00007ffeefbff778:  0x00000000041e5f30  0x00000000043059c0 

0x00007ffeefbff788:  0x00007ffeefbff7d8  0x0000000004069465 <runtime.mstart+0x0000000000000005> 

0x00007ffeefbff798:  0x000000000406941d <runtime.rt0_go+0x000000000000013d> 

runtime.throw({0x41b5e63, 0x42af028})

/usr/local/Cellar/go/1.17.1/libexec/src/runtime/panic.go:1198 +0x71

runtime: unexpected return pc for runtime.sigpanic called from 0x7fff672e870a

stack: frame={sp:0x7ffeefbff698, fp:0x7ffeefbff6e8} stack=[0x7ffeefb80738,0x7ffeefbff7a0)

0x00007ffeefbff598:  0x01007ffeefbff5b8  0x0000000000000004 

0x00007ffeefbff5a8:  0x000000000000001f  0x00007fff672e870a 

0x00007ffeefbff5b8:  0x0b01dfacedebac1e  0x0000000000000001 

0x00007ffeefbff5c8:  0x0000000004039b11 <runtime.throw+0x0000000000000071>  0x00007ffeefbff668 

0x00007ffeefbff5d8:  0x00000000041b2eb6  0x00007ffeefbff620 

0x00007ffeefbff5e8:  0x0000000004039dc8 <runtime.fatalthrow.func1+0x0000000000000048>  0x00000000043059c0 

0x00007ffeefbff5f8:  0x0000000000000001  0x0000000000000001 

0x00007ffeefbff608:  0x00007ffeefbff668  0x0000000004039b11 <runtime.throw+0x0000000000000071> 

0x00007ffeefbff618:  0x00000000043059c0  0x00007ffeefbff658 

0x00007ffeefbff628:  0x0000000004039d50 <runtime.fatalthrow+0x0000000000000050>  0x00007ffeefbff638 

0x00007ffeefbff638:  0x0000000004039d80 <runtime.fatalthrow.func1+0x0000000000000000>  0x00000000043059c0 

0x00007ffeefbff648:  0x0000000004039b11 <runtime.throw+0x0000000000000071>  0x00007ffeefbff668 

0x00007ffeefbff658:  0x00007ffeefbff688  0x0000000004039b11 <runtime.throw+0x0000000000000071> 

0x00007ffeefbff668:  0x00007ffeefbff670  0x0000000004039b40 <runtime.throw.func1+0x0000000000000000> 

0x00007ffeefbff678:  0x00000000041b5e63  0x000000000000002a 

0x00007ffeefbff688:  0x00007ffeefbff6d8  0x000000000404fd76 <runtime.sigpanic+0x0000000000000396> 

0x00007ffeefbff698: <0x00000000041b5e63  0x00000000042af028 

0x00007ffeefbff6a8:  0x00000000042d4ec0  0x00000000040c040a <testing.(*T).Run·dwrap·21+0x000000000000002a> 

0x00007ffeefbff6b8:  0x000000c0001943b0  0x0000000004011d5e <runtime.mallocgc+0x000000000000065e> 

0x00007ffeefbff6c8:  0x000000c00018a680  0x0000000000000000 

0x00007ffeefbff6d8:  0x00007ffeefbff720 !0x00007fff672e870a 

0x00007ffeefbff6e8: >0x00007ffeefbff720  0x00000000042cc000 

0x00007ffeefbff6f8:  0x0000000000000920  0x00000000040f99e5 <golang.org/x/sys/unix.libc_ioctl_trampoline+0x0000000000000005

0x00007ffeefbff708:  0x000000000406d5ff <runtime.syscall+0x000000000000001f>  0x000000c000054578 

0x00007ffeefbff718:  0x000000000406cf6c <runtime.nanotime_trampoline+0x000000000000000c>  0x000000c000054548 

0x00007ffeefbff728:  0x000000000406b450 <runtime.asmcgocall+0x0000000000000070>  0x0000000000000002 

0x00007ffeefbff738:  0x000000c000194758  0x0000000000000001 

0x00007ffeefbff748:  0x0000000000000000  0x000000c0000001a0 

0x00007ffeefbff758:  0x0000000000000ae0  0x000000c00018a680 

0x00007ffeefbff768:  0x000000000406964b <runtime.morestack+0x000000000000008b>  0x0000000000000004 

0x00007ffeefbff778:  0x00000000041e5f30  0x00000000043059c0 

0x00007ffeefbff788:  0x00007ffeefbff7d8  0x0000000004069465 <runtime.mstart+0x0000000000000005> 

0x00007ffeefbff798:  0x000000000406941d <runtime.rt0_go+0x000000000000013d> 

runtime.sigpanic()

/usr/local/Cellar/go/1.17.1/libexec/src/runtime/signal_unix.go:719 +0x396


goroutine 35 [syscall]:

syscall.syscall(0x40f99e0, 0x2, 0x40487413, 0xc000054608)

/usr/local/Cellar/go/1.17.1/libexec/src/runtime/sys_darwin.go:22 +0x3b fp=0xc000054578 sp=0xc000054558 pc=0x406811b

syscall.syscall(0x3, 0x13, 0x10, 0xd0)

<autogenerated>:1 +0x26 fp=0xc0000545c0 sp=0xc000054578 pc=0x406dd66

golang.org/x/sys/unix.ioctl(0x4014a39, 0xc000054628, 0x4017bcc)

/Users/xvt/go/pkg/mod/golang.org/x/s...@v0.0.0-20191026070338-33540a1f6037/unix/zsyscall_darwin_amd64.go:746 +0x39 fp=0xc0000545f0 sp=0xc0000545c0 pc=0x40f9679

golang.org/x/sys/unix.IoctlGetTermios(...)

/Users/xvt/go/pkg/mod/golang.org/x/s...@v0.0.0-20191026070338-33540a1f6037/unix/ioctl.go:63

github.com/sirupsen/logrus.isTerminal(0x922f9fe174c3820c)

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/terminal_check_bsd.go:11 +0x50 fp=0xc000054660 sp=0xc0000545f0 pc=0x40fb410

github.com/sirupsen/logrus.checkIfTerminal({0x41e7360, 0xc00011a010})

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/terminal_check_notappengine.go:13 +0x75 fp=0xc000054678 sp=0xc000054660 pc=0x40fb4b5

github.com/sirupsen/logrus.(*TextFormatter).init(0xc00011c4e0, 0x6773538)

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/text_formatter.go:103 +0x34 fp=0xc0000546f8 sp=0xc000054678 pc=0x40fb594

github.com/sirupsen/logrus.(*TextFormatter).Format.func1()

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/text_formatter.go:193 +0x25 fp=0xc000054718 sp=0xc0000546f8 pc=0x40fcc45

sync.(*Once).doSlow(0x41ea518, 0xc0001341b0)

/usr/local/Cellar/go/1.17.1/libexec/src/sync/once.go:68 +0xd2 fp=0xc000054780 sp=0xc000054718 pc=0x4071c72

sync.(*Once).Do(...)

/usr/local/Cellar/go/1.17.1/libexec/src/sync/once.go:59

github.com/sirupsen/logrus.(*TextFormatter).Format(0xc00011c4e0, 0xc0001882a0)

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/text_formatter.go:193 +0xebe fp=0xc000054cf0 sp=0xc000054780 pc=0x40fc5fe

github.com/sirupsen/logrus.(*Entry).write(0xc0001882a0)

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/entry.go:271 +0xa5 fp=0xc000054d68 sp=0xc000054cf0 pc=0x40fa565

github.com/sirupsen/logrus.Entry.log({0xc000188000, 0xc000115380, {0x0, 0x0, 0x0}, 0x0, 0x0, {0x0, 0x0}, 0x0, ...}, ...)

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/entry.go:247 +0x25a fp=0xc000054de0 sp=0xc000054d68 pc=0x40fa1fa

github.com/sirupsen/logrus.(*Entry).Log(0xc000188230, 0x4, {0xc000194750, 0x3a, 0x474})

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/entry.go:283 +0xa8 fp=0xc000054ee8 sp=0xc000054de0 pc=0x40fa788

github.com/sirupsen/logrus.(*Logger).Log(0xc000188000, 0x4, {0xc000194750, 0x1, 0x1})

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/logger.go:198 +0x65 fp=0xc000054f28 sp=0xc000054ee8 pc=0x40fb0c5

github.com/sirupsen/logrus.(*Logger).Info(...)

/Users/xvt/go/pkg/mod/github.com/sirupsen/log...@v1.7.0/logger.go:220

credential_mgmt/util.TestSomething(0x0)

/Users/xvt/go/src/credential_mgmt/util/util_test.go:36 +0x5e fp=0xc000054f70 sp=0xc000054f28 pc=0x4161cfe

testing.tRunner(0xc00018a4e0, 0x41bda20)

/usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1259 +0x102 fp=0xc000054fc0 sp=0xc000054f70 pc=0x40bf702

testing.(*T).Run·dwrap·21()

/usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1306 +0x2a fp=0xc000054fe0 sp=0xc000054fc0 pc=0x40c040a

runtime.goexit()

/usr/local/Cellar/go/1.17.1/libexec/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000054fe8 sp=0xc000054fe0 pc=0x406b741

created by testing.(*T).Run

/usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1306 +0x35a


goroutine 1 [chan receive]:

testing.(*T).Run(0xc00018a340, {0x41ad7c2, 0x43878ce1a577b}, 0x41bda20)

/usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1307 +0x375

testing.runTests.func1(0xc000115350)

/usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1598 +0x6e

testing.tRunner(0xc00018a340, 0xc00016dd18)

/usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1259 +0x102

testing.runTests(0xc000164080, {0x42fb620, 0x1, 0x1}, {0x407cb6d, 0x41add54, 0x0})

/usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1596 +0x43f

testing.(*M).Run(0xc000164080)

/usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1504 +0x51d

main.main()

_testmain.go:43 +0x14b


Sean Liao

unread,
Sep 23, 2021, 2:46:00 PM9/23/21
to golang-nuts
update your version of golang.org/x/sys
Reply all
Reply to author
Forward
0 new messages