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

runtime: bad pointer in frame github.com/konsorten/go-windows-terminal-sequences.EnableVirtualTerminalProcessing #1112

Closed
lkebin opened this issue Mar 12, 2020 · 16 comments · Fixed by #1137
Assignees

Comments

@lkebin
Copy link

lkebin commented Mar 12, 2020

The following code snippet doesn't work on Windows 10, but works on macOS and Linux.

package main

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

func main() {
	c := make(chan int, 1)

	go func() {
		logrus.Info("hello world")
		c <- 1
	}()

	<-c
}
runtime: bad pointer in frame github.com/konsorten/go-windows-terminal-sequences.EnableVirtualTerminalProcessing at 0xc00007f6c0: 0x60
fatal error: invalid pointer found on stack

runtime stack:
runtime.throw(0x4f4e6c, 0x1e)
        c:/go/src/runtime/panic.go:1112 +0x79 fp=0x89f790 sp=0x89f760 pc=0x432ac9
runtime.adjustpointers(0xc00007f6c0, 0x89f890, 0x89fc20, 0x594af0, 0x59faa0)
        c:/go/src/runtime/stack.go:599 +0x22e fp=0x89f7f0 sp=0x89f790 pc=0x44619e
runtime.adjustframe(0x89fb30, 0x89fc20, 0x59faa0)
        c:/go/src/runtime/stack.go:641 +0x355 fp=0x89f8c0 sp=0x89f7f0 pc=0x446505
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc000038f00, 0x0, 0x0, 0x7fffffff, 0x4f8bf0, 0x89fc20, 0x0, ...)               c:/go/src/runtime/traceback.go:334 +0x111c fp=0x89fb98 sp=0x89f8c0 pc=0x45272c
runtime.copystack(0xc000038f00, 0x4000)
        c:/go/src/runtime/stack.go:888 +0x298 fp=0x89fd50 sp=0x89fb98 pc=0x446c28
runtime.newstack()
        c:/go/src/runtime/stack.go:1043 +0x219 fp=0x89fee0 sp=0x89fd50 pc=0x446ef9
runtime.morestack()
        c:/go/src/runtime/asm_amd64.s:449 +0x97 fp=0x89fee8 sp=0x89fee0 pc=0x45b997

goroutine 6 [copystack]:
runtime.concatstrings(0xc00007f3f0, 0xc00007f3c0, 0x2, 0x2, 0x0, 0x0)
        c:/go/src/runtime/string.go:23 +0x2e0 fp=0xc00007f378 sp=0xc00007f370 pc=0x448940
runtime.concatstring2(0xc00004d3f0, 0x4f02a1, 0xc, 0x4eee7a, 0x1, 0x0, 0x0)
        c:/go/src/runtime/string.go:58 +0x4e fp=0xc00007f3b8 sp=0xc00007f378 pc=0x44899e
syscall.UTF16FromString(0x4f02a1, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0)
        c:/go/src/syscall/syscall_windows.go:45 +0xcc fp=0xc00007f4a0 sp=0xc00007f3b8 pc=0x48d60c
syscall.UTF16PtrFromString(...)
        c:/go/src/syscall/syscall_windows.go:91
syscall.LoadDLL(0x4f02a1, 0xc, 0xc00004d598, 0x43c973, 0xc000038f00)
        c:/go/src/syscall/dll_windows.go:69 +0x54 fp=0xc00007f558 sp=0xc00007f4a0 pc=0x48ae74
syscall.(*LazyDLL).Load(0xc0000044a0, 0x0, 0x0)
        c:/go/src/syscall/dll_windows.go:236 +0xc7 fp=0xc00007f5a8 sp=0xc00007f558 pc=0x48cb87
syscall.(*LazyProc).Find(0xc000068330, 0x0, 0x0)
        c:/go/src/syscall/dll_windows.go:291 +0xbe fp=0xc00007f600 sp=0xc00007f5a8 pc=0x48cdfe
syscall.(*LazyProc).mustFind(0xc000068330)
        c:/go/src/syscall/dll_windows.go:309 +0x32 fp=0xc00007f628 sp=0xc00007f600 pc=0x48cf22
syscall.(*LazyProc).Call(0xc000068330, 0xc000010120, 0x2, 0x2, 0x4f8ef8, 0xc00004d6f8, 0x48ebd6, 0x7ffb01422820)
        c:/go/src/syscall/dll_windows.go:327 +0x36 fp=0xc00007f678 sp=0xc00007f628 pc=0x48cff6
github.com/konsorten/go-windows-terminal-sequences.EnableVirtualTerminalProcessing(0x60, 0x1, 0x0, 0xc00004d72c)
        C:/Users/lkebin/go/pkg/mod/github.com/konsorten/[email protected]/sequences.go:30 +0xcb fp=0xc00007f6d8 sp=0xc00007f678 pc=0x4b481b
github.com/sirupsen/logrus.initTerminal(0x510a20, 0xc000006020)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/terminal_check_windows.go:16 +0x64 fp=0xc00007f708 sp=0xc00007f6d8 pc=0x4b6e34
github.com/sirupsen/logrus.checkIfTerminal(0x510a20, 0xc000006020, 0x1b0108)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/terminal_check_windows.go:31 +0xb4 fp=0xc00007f740 sp=0xc00007f708 pc=0x4b6f14
github.com/sirupsen/logrus.(*TextFormatter).init(...)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/text_formatter.go:86
github.com/sirupsen/logrus.(*TextFormatter).Format.func1()
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/text_formatter.go:170 +0x58 fp=0xc00007f770 sp=0xc00007f740 pc=0x4b9cb8 sync.(*Once).doSlow(0xc0000500e0, 0xc00004d9a0)
        c:/go/src/sync/once.go:66 +0xf3 fp=0xc00007f7c0 sp=0xc00007f770 pc=0x46f9f3
sync.(*Once).Do(...)
        c:/go/src/sync/once.go:57
github.com/sirupsen/logrus.(*TextFormatter).Format(0xc0000500a0, 0xc00008c0e0, 0xc00004dd78, 0x4b9b54, 0x4dbe80, 0xc0000683f0, 0xc00004ddc0)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/text_formatter.go:170 +0xf1d fp=0xc00007fd48 sp=0xc00007f7c0 pc=0x4b7fedgithub.com/sirupsen/logrus.(*Entry).write(0xc00008c0e0)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/entry.go:255 +0x83 fp=0xc00007fdd0 sp=0xc00007fd48 pc=0x4b56b3
github.com/sirupsen/logrus.Entry.log(0xc00008c000, 0xc0000683c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/entry.go:231 +0x1a5 fp=0xc00007fe48 sp=0xc00007fdd0 pc=0x4b5355
github.com/sirupsen/logrus.(*Entry).Log(0xc00008c070, 0xc000000004, 0xc00004dfb8, 0x1, 0x1)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/entry.go:268 +0xf2 fp=0xc00007ff50 sp=0xc00007fe48 pc=0x4b5942
github.com/sirupsen/logrus.(*Logger).Log(0xc00008c000, 0x4, 0xc00004dfb8, 0x1, 0x1)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/logger.go:192 +0x84 fp=0xc00007ff90 sp=0xc00007ff50 pc=0x4b6694
github.com/sirupsen/logrus.(*Logger).Info(...)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/logger.go:206
github.com/sirupsen/logrus.Info(...)
        C:/Users/lkebin/go/pkg/mod/github.com/sirupsen/[email protected]/exported.go:109
main.main.func1(0xc0000160e0)
        C:/Users/lkebin/Workspace/playground/log/main.go:11 +0x7c fp=0xc00007ffd8 sp=0xc00007ff90 pc=0x4ba13c
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00007ffe0 sp=0xc00007ffd8 pc=0x45d9c1
created by main.main
        C:/Users/lkebin/Workspace/playground/log/main.go:10 +0x5f

goroutine 1 [chan receive]:
runtime.gopark(0x4f8c60, 0xc000016138, 0x170e, 0x2)
        c:/go/src/runtime/proc.go:304 +0xf5 fp=0xc000087e98 sp=0xc000087e78 pc=0x435555
runtime.chanrecv(0xc0000160e0, 0x0, 0xc000038001, 0x4ba08f)
        c:/go/src/runtime/chan.go:525 +0x2f5 fp=0xc000087f28 sp=0xc000087e98 pc=0x4058a5
runtime.chanrecv1(0xc0000160e0, 0x0)
        c:/go/src/runtime/chan.go:407 +0x2b fp=0xc000087f58 sp=0xc000087f28 pc=0x40555b
main.main()
        C:/Users/lkebin/Workspace/playground/log/main.go:15 +0x76 fp=0xc000087f88 sp=0xc000087f58 pc=0x4ba0a6
runtime.main()
        c:/go/src/runtime/proc.go:203 +0x212 fp=0xc000087fe0 sp=0xc000087f88 pc=0x435182
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc000087fe8 sp=0xc000087fe0 pc=0x45d9c1

goroutine 2 [force gc (idle)]:
runtime.gopark(0x4f8e28, 0x5b1a90, 0x1411, 0x1)
        c:/go/src/runtime/proc.go:304 +0xf5 fp=0xc00003bfb0 sp=0xc00003bf90 pc=0x435555
runtime.goparkunlock(...)
        c:/go/src/runtime/proc.go:310
runtime.forcegchelper()
        c:/go/src/runtime/proc.go:253 +0xc5 fp=0xc00003bfe0 sp=0xc00003bfb0 pc=0x4353f5
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00003bfe8 sp=0xc00003bfe0 pc=0x45d9c1
created by runtime.init.6
        c:/go/src/runtime/proc.go:242 +0x3c

goroutine 3 [GC sweep wait]:
runtime.gopark(0x4f8e28, 0x5b1ba0, 0x140c, 0x1)
        c:/go/src/runtime/proc.go:304 +0xf5 fp=0xc00003dfa8 sp=0xc00003df88 pc=0x435555
runtime.goparkunlock(...)
        c:/go/src/runtime/proc.go:310
runtime.bgsweep(0xc000016070)
        c:/go/src/runtime/mgcsweep.go:70 +0xaa fp=0xc00003dfd8 sp=0xc00003dfa8 pc=0x420eca
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00003dfe0 sp=0xc00003dfd8 pc=0x45d9c1
created by runtime.gcenable
        c:/go/src/runtime/mgc.go:214 +0x63

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x4f8e28, 0x5b1b60, 0x140d, 0x1)
        c:/go/src/runtime/proc.go:304 +0xf5 fp=0xc00004bf78 sp=0xc00004bf58 pc=0x435555
runtime.goparkunlock(...)
        c:/go/src/runtime/proc.go:310
runtime.bgscavenge(0xc000016070)
        c:/go/src/runtime/mgcscavenge.go:237 +0xde fp=0xc00004bfd8 sp=0xc00004bf78 pc=0x41f46e
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00004bfe0 sp=0xc00004bfd8 pc=0x45d9c1
created by runtime.gcenable
        c:/go/src/runtime/mgc.go:215 +0x85

goroutine 5 [finalizer wait]:
runtime.gopark(0x4f8e28, 0x5dd0d0, 0x4c1410, 0x1)
        c:/go/src/runtime/proc.go:304 +0xf5 fp=0xc00003ff58 sp=0xc00003ff38 pc=0x435555
runtime.goparkunlock(...)
        c:/go/src/runtime/proc.go:310
runtime.runfinq()
        c:/go/src/runtime/mfinal.go:175 +0xb1 fp=0xc00003ffe0 sp=0xc00003ff58 pc=0x4169e1
runtime.goexit()
        c:/go/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00003ffe8 sp=0xc00003ffe0 pc=0x45d9c1
created by runtime.createfing
        c:/go/src/runtime/mfinal.go:156 +0x68
@nathan-osman
Copy link

nathan-osman commented Mar 28, 2020

I'm seeing this too. It seems like v1.1.1 (bcd833d) is the most recent release that does not cause the error.

@xin478
Copy link

xin478 commented Apr 1, 2020

I'm seeing this too.

@latifrons
Copy link

I'm seeing this also.

@latifrons
Copy link

latifrons commented Apr 3, 2020

Using Go 1.13 instead of 1.14 solves the problem.
If you must use Go 1.14, see the following solution.

Environment: Windows 10 1909 Build 18363.720
Go 1.14,Logrus any version.
It is really weird that adding a print statement in the 3rd party lib may solve this problem.
However the problem is probably related to the console, so fmt.Println() may have some magic effects.

image

Something has changed or there is a bug in the Go 1.14 stack management.

@dgsb
Copy link
Collaborator

dgsb commented Apr 3, 2020

I do not have any available windows environment to work on that.
I suspect though the problem is located in konsorten package, have tried to open an issue there ?

@yufengjinsong
Copy link

Using Go 1.13 instead of 1.14 solves the problem.
If you must use Go 1.14, see the following solution.

Environment: Windows 10 1909 Build 18363.720
Go 1.14,Logrus any version.
It is really weird that adding a print statement in the 3rd party lib may solve this problem.
However the problem is probably related to the console, so fmt.Println() may have some magic effects.

image

Something has changed or there is a bug in the Go 1.14 stack management.

这个问题真的恶心到我了 ,浪费了两天时间在这个上面了 终于解决了 ,thanks very much

@lkebin
Copy link
Author

lkebin commented Apr 17, 2020

Using Go 1.13 instead of 1.14 solves the problem.
If you must use Go 1.14, see the following solution.
Environment: Windows 10 1909 Build 18363.720
Go 1.14,Logrus any version.
It is really weird that adding a print statement in the 3rd party lib may solve this problem.
However the problem is probably related to the console, so fmt.Println() may have some magic effects.
image
Something has changed or there is a bug in the Go 1.14 stack management.

这个问题真的恶心到我了 ,浪费了两天时间在这个上面了 终于解决了 ,thanks very much

So, what's your solution ?

@dgsb
Copy link
Collaborator

dgsb commented Apr 17, 2020

I think the issue is related to this package https://github.com/konsorten/go-windows-terminal-sequences and go 1.14
An issue should be opened there instead.

@lkebin
Copy link
Author

lkebin commented Apr 17, 2020

I think the issue is related to this package https://github.com/konsorten/go-windows-terminal-sequences and go 1.14
An issue should be opened there instead.

You are right, the issue may caused by konsorten/go-windows-terminal-sequences package. Actually, has a issue created https://github.com/konsorten/go-windows-terminal-sequences/issues/4.

@dylannz
Copy link

dylannz commented Apr 19, 2020

I ran into this after adding a call to logrus.SetLevel. If I set the level using logrus.SetLevel, then subsequent logging calls result in a panic.

If I remove the call to logrus.SetLevel, then the panic goes away. It does not seem to matter what level I set it to, just that I've set it at all...

EDIT: in hindsight, it's pretty temperamental, and removing this SetLevel call does not always seem to work.

@yufengjinsong
Copy link

Using Go 1.13 instead of 1.14 solves the problem.
If you must use Go 1.14, see the following solution.
Environment: Windows 10 1909 Build 18363.720
Go 1.14,Logrus any version.
It is really weird that adding a print statement in the 3rd party lib may solve this problem.
However the problem is probably related to the console, so fmt.Println() may have some magic effects.
image
Something has changed or there is a bug in the Go 1.14 stack management.

这个问题真的恶心到我了 ,浪费了两天时间在这个上面了 终于解决了 ,thanks very much

So, what's your solution ?

just do as the picture says

@fkollmann
Copy link
Contributor

fkollmann commented Apr 28, 2020

EDIT: @dirty49374 proposed a fix which works. I confirmed that is now working for the example above.

@fkollmann
Copy link
Contributor

@dgsb
Copy link
Collaborator

dgsb commented Apr 28, 2020

so we just need to update our dependencies to have the fix then

@lkebin
Copy link
Author

lkebin commented Apr 28, 2020

@dgsb should wait logrus release new version to include go-windows-terminal-sequences patch version

@dgsb
Copy link
Collaborator

dgsb commented Apr 29, 2020

Thanks for the fix @fkollmann 👍

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

Successfully merging a pull request may close this issue.

8 participants