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
cgo: include symbol version information #1397
Labels
Comments
Here's a better ib.go that doesn't use C.strncmp. Same problem though. Attachments:
|
Owner changed to r...@golang.org. Status changed to NeedsAttention. |
And the diff... can't really see anything significant. Attachments:
|
You're right that not much changed! I was assuming that the call was returning the right value. I guess the next step is to verify that assumption. Can you make a wrapper my_ibv_get_device_list that calls ibv_get_device_list, prints the result using %p, and returns it? And then print the same result from Go (using %p) and see if they match? If they match, then it has to be a data structure issue. If they don't match, then it's a cgo calling issue. Status changed to WaitingForReply. |
Okay, I added a little wrapper: /* #include <stdio.h> #include <infiniband/verbs.h> struct ibv_device **my_ibv_get_device_list(int *num_devices) { struct ibv_device** devs = ibv_get_device_list(num_devices); printf("devs=%p\n", devs); printf("devs[0]->node_type=%d\n", devs[0]->node_type); return devs; } */ It prints: devs=0x2223040 devs[0]->node_type=1 deviceList=0x2223040 so the pointer makes it through fine and the struct is intact. But with the new cgo: devs=0x8e70f8 devs[0]->node_type=9303872 deviceList=0x8e70f8 So the pointers are fine, but the struct is already corrupted before Go gets it. As a last resort, I ran valgrind 3.5.0 on the binary. It almost works! Things run for a while and then something segfaults. There's some interesting warnings that might warrant your attention. Output attached. Attachments:
|
I found the problem. The libibverbs shared library contains two versions of ibv_get_device_list: ibv_get_device_list@IBVERBS_1.0 and ibv_get_device_list@@IBVERBS_1.1. Because the files generated by 6l do not include library version information, the dynamic linker gives us the oldest one. But in fact we want the newer one. Using the old cgo model, 6l output never referred to system .so files directly (only indirectly via the stub .so files, which had proper version information). The fix will be to include the version information. It shouldn't be too hard. Status changed to Accepted. |
Hello gopack prints: fwrite libc.so.6 GLIBC_2.2.5 stderr libc.so.6 GLIBC_2.2.5 pthread_attr_init libpthread.so.0 GLIBC_2.2.5 pthread_attr_getstacksize libpthread.so.0 GLIBC_2.2.5 pthread_create libpthread.so.0 GLIBC_2.2.5 free libc.so.6 GLIBC_2.2.5 malloc libc.so.6 GLIBC_2.2.5 abort libc.so.6 GLIBC_2.2.5 __errno_location libc.so.6 GLIBC_2.2.5 ibv_get_device_list libibverbs.so.1 IBVERBS_1.1 strncmp libc.so.6 GLIBC_2.2.5 x1 which has the line: ibv_get_device_list libibverbs.so.1 IBVERBS_1.1 which looks good. But when I run my test case I attached here, I still get: device=&{ops:{alloc_context:<nil> free_context:<nil>} node_type:59442928 transport_type:0 ...} which still looks like the wrong function is being called. |
This issue was closed by revision 09092a7. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Attachments:
The text was updated successfully, but these errors were encountered: