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
debug/dwarf: cgo use causing build panic #13039
Comments
/cc @aclements |
Awesome. Here's the relevant readelf output for the cgo-generated source:
The cause of the problem is that the two typedefs at 0x19 and 0x45 participate in a cycle. We start reading at the 0x19 typedef, put it in the type cache, then start constructing its underlying type. At this point, its "Type" field is still nil. This reads the pointer type at 0x24, which reads the struct type at 0x2a, which reads the typedef at 0x45, which reads the typedef at 0x19. This is in the cache, so we return it immediately, but then the readType of the 0x45 typedef tries to get its size and crashes because the 0x19 Type field is still nil. I think we simply can't combine the steps of constructing the type graph and computing type sizes because these two steps may need to ground out at different points in cycles. Reading always terminates the cycle where it entered it, which is the 0x19 typedef here, but computing the size needs to terminate the cycle in a basic or pointer type, which is the 0x24 pointer here. |
CL https://golang.org/cl/18459 mentions this issue. |
Lovely, thanks for the assistance! The typedef lies I used to sidestep this problem were a bit brutal. It was a joy to remove them. |
This is a brute force workaround for golang/go#13039
golang/go#13039 has been fixed for go1.6 so we no longer need to hide SV* and tTHX from go. Hopefully some trampoline functions can be eliminated as well, but that'll be another pass.
I have a go code example that is causing "go build" to panic using go version go1.5.1 linux/amd64. The C struct declaration in that sample is awkward, but is a simplification of a pattern I found in upstream library headers.
reproduces the problem. I found that a small patch to the go sources will allow this example to build and run cleanly, but it's not a good solution and it's not portable code.
which assumes that any time t.Type is not defined it's always an opaque struct pointer, and futher assumes that pointers are always 8 bytes. I'm certain a better solution is possible.
The text was updated successfully, but these errors were encountered: