-
Notifications
You must be signed in to change notification settings - Fork 18k
Cannot recover from nil pointer dereference on Windows when Control Flow Guard is enabled #53560
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Strange. Go does not generate CFG-enabled binaries (see #35940) nor I can reproduce your issue with Windows 11 10.0.22000. Which Windows version are you using? |
I noticed some weird things when trying to reproduce the issue. On some other windows machine, I had to change the Exploit Protection -> Control Flow Guard to "On by default" and restart to make this issue happen. For strange reasons, "Use default(on)" didn't lead to any problem. Also, I am on Windows 11 Insider Preview 10.0.25145.1011. |
I can confirm that switching CFG to "On by default" makes the program crash. No clue on what the cause could be. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
This issue report is valid and should be reopened. I don't think we need more info, just investigation. |
This is what I get from WinDbg:
I can see that
go/src/runtime/sys_windows_arm.s Lines 184 to 192 in 690851e
I've tried porting the workaround to windows/amd64, but my assembly skills are not that good yet. |
Change https://go.dev/cl/437559 mentions this issue: |
I've finally gave it a try in CL 437559. |
The stack pointer must lie within system stack limits when Control Flow Guard (CFG) is enabled on Windows. This CL updates runtime.sigtramp to honor this restriction by porting some code from the windows/arm64 version, which already supports CFG. Fixes golang#53560 Change-Id: I7f88f9ae788b2bac38aac898b2567f1bea62f8f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/437559 Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried to run this
with go run main.go command
What did you expect to see?
I expected the output to be,
caught error runtime error: invalid memory address or nil pointer dereference
What did you see instead?
The output was,
exit status 0xc0000409
It works if I disable the CFG(Control Flow Guard) feature under windows exploit protection settings or add the generated binary as an exception for CFG.
I encountered this same problem when running another golang project, grpcui, on windows https://github.com/fullstorydev/grpcui. The problem there is also fixed by disabled CFG.
I wonder if this is an issue/bug with how the golang compiler produces the binary for windows.
Always asking end-users to manually add a CFG exception for golang generated binaries doesn't seem right. (Maybe it's correct if the issue is indeed on the Windows end).
The text was updated successfully, but these errors were encountered: