Closed
Description
What steps will reproduce the problem? Reproducing the problem is a bit tricky, since you need to call a function on the ibverbs C library that is only going to return the right stuff if you have an InfiniBand controller in your machine. I tried to make my own little shared library with a simplified version of the function and the same structs as what produces the error, but it didn't reproduce the problem. If there's anything I can check with gdb that could help, let me know. I have the ibverbs debuginfo, so I can set breakpoints in it and in my Go code. So here goes... What is the expected output? With release.2010-12-08 (the old cgo), I get the following structs returned from the C function: struct ibv_device **ibv_get_device_list(int *num_devices) The values: deviceList=0x17fd3c0 &device=0x17f5740 device=&{ops:{alloc_context:0x7f8ef46d7480 free_context:0x7f8ef46d72b0} node_type:1 transport_type:0 name:[109 108 120 52 95 48 0 ...] dev_name:[117 118 101 114 98 115 48 0 ...] dev_path:[47 115 121 115 47 99 108 97 115 115 47 105 110 102 105 110 105 98 97 110 100 95 118 101 114 98 115 47 117 118 101 114 98 115 48 0 ...] ibdev_path:[47 115 121 115 47 99 108 97 115 115 47 105 110 102 105 110 105 98 97 110 100 47 109 108 120 52 95 48 0 ...]} What do you see instead? deviceList=0x1b40048 &device=0x1b40710 device=&{ops:{alloc_context:<nil> free_context:<nil>} node_type:28575552 transport_type:0 name:[garbage0] dev_name:[garbage] dev_path:[garbage] ibdev_path:[garbage]} Basically the whole struct is corrupted. Which compiler are you using (5g, 6g, 8g, gccgo)? 6g Which operating system are you using? linux Which revision are you using? (hg identify) tip release.2010-12-08 with the old cgo works fine. Please provide any additional information below. The C function looks like this: struct ibv_device **ibv_get_device_list(int *num_devices) And the structs involved: enum { IBV_SYSFS_NAME_MAX = 64, IBV_SYSFS_PATH_MAX = 256 }; struct ibv_device_ops { void *p1; // actually a function pointer void *p2; // actually a function pointer }; enum ibv_node_type { IBV_NODE_UNKNOWN = -1, IBV_NODE_CA = 1, IBV_NODE_SWITCH, IBV_NODE_ROUTER, IBV_NODE_RNIC }; enum ibv_transport_type { IBV_TRANSPORT_UNKNOWN = -1, IBV_TRANSPORT_IB = 0, IBV_TRANSPORT_IWARP }; struct ibv_device { struct ibv_device_ops ops; enum ibv_node_type node_type; enum ibv_transport_type transport_type; char name[IBV_SYSFS_NAME_MAX]; char dev_name[IBV_SYSFS_NAME_MAX]; char dev_path[IBV_SYSFS_PATH_MAX]; char ibdev_path[IBV_SYSFS_PATH_MAX]; };
Attachments:
- ib.go (893 bytes)
- Makefile (107 bytes)
- ib_test.go (267 bytes)