-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/cgo: Null pointer is accessed in C code, causing the stack to be destroyed #41070
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
Comments
The traceback the runtime prints when crashing looks fine:
(But it of course doesn't contain the C part of the stack.) I can reproduce the gdb problem you're seeing. When run under gdb directly, the stack trace is even weirder. Delve handles this just fine, although it also doesn't show the C parts:
Not sure why gdb/lldb can't backtrace the Go side. We do generate Dwarf, but maybe it's not sufficient to encode things like stack switches? Or maybe it is just wrong? gdb behavior can vary a lot by version. I used:
|
I'm fairly certain that the stack has not been destroyed. It's just that gdb has gotten confused. Which version of gdb are you using? |
gdb version: GNU gdb (Ubuntu 9.1-0ubuntu1) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Please use |
The problem seems to be because we are calling The unwind info for
Interestingly this doesn't record any location for the saved value for
which also does not list I'm not sure but I think that the effect of this is that when gdb unwinds past I spot checked the unwind info of a couple of other Go frames, and they also don't record any information about where I don't plan to look into this any further myself. |
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?
test.cpp:
test.h:
main.go:
build cmd:
then run
env GOTRACEBACK=crash ./main
the core dump is:
What did you expect to see?
code is:
I expect
this
pointer to be 0, and the stack is not destroyedWhat did you see instead?
#13 0x000000000047fa06 in A::release (this=0x47fa06 <A::release()+20>) at test.cpp:33
this
pointer is0x47fa06
andBacktrace stopped: previous frame inner to this frame (corrupt stack?)
The text was updated successfully, but these errors were encountered: