-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/cgo: "function symbol table not sorted by program counter" crash when using multiple shared libraries linked with -buildmode=c-archive #30822
Comments
Is there any further information I could provide to help investigate the cause of this issue? Also, is this a previously known issue or limitation of Cgo interaction with Go? The scenario is as follows. We have a C program
Given this setup, the resulting binary If we change the scenario to not invoke any Go function in So, from what I can tell, it seems that only one shared library may have Cgo code in it (produced with Cheers, |
A quick update. @acln0 helped me do some initial trouble shooting. We've now reproduced this issue on two machines (and on both 32-bit and 64-bit builds). |
We could further conclude that the issue is with the One way of doing so was to insert a call to
|
With the current implementation it's not going to work to use |
Hi @ianlancetaylor. Thanks for the input. One question, when we generate multiple shared libraries using I would assume there are If there is a design document, or specific parts of the runtime source code I could attend to to gain further insight into this, I'd be very curious to learn more. Kindly, |
The -buildmode=c-shared libraries differ in that they are built with I guess you could do the same with your shared libraries, if your C code doesn't mind being linked with There is a design doc but I'm not sure it helps with this level of detail: https://golang.org/s/execmodes. |
Thank you @ianlancetaylor for the suggestion and insight! This resolved the issue outlined in golang/go#30822.
Thank you so much @ianlancetaylor! Your insight is invaluable. Indeed, adding Thanks once more :) Cheerful regards, |
What version of Go are you using (
go version
)?I also tried to run this on the Go 1.12 release, and the same crash happens there.
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?
For a minimal reproducible example code see: https://github.com/mewspring/go-cgo-issue
$ git clone https://github.com/mewspring/go-cgo-issue $ cd go-cgo-issue/foo $ make -B $ ./foo ... fatal error: cgo callback before cgo call
In essence, I have a minimal C program that invokes multiple shared libraries, each one written in C and linked with Go code using
-buildmode=c-archive
.The program works great when invoking Go code from C this way when using one library. However, when you invoke Go functions from more than one library, the program crashes with the following error message.
Note: if we simply uncomment one line (https://github.com/mewspring/go-cgo-issue/blob/d03e251e54cc0a6821bee5fb15c52d69e90c08d7/c/c.c#L12), the invocation of the Go function
FooBar
in thec.so
library, then the program works as expected.What did you expect to see?
No crash. In particular, I expected to see the output:
And a status code of 0.
What did you see instead?
The crash "fatal error: cgo callback before cgo call" crash.
The text was updated successfully, but these errors were encountered: