c -崩溃在开放(接收SIGBUS)



我的一个应用程序由于SIGBUS信号而崩溃。下面是来自gdb的堆栈跟踪。基本上,开放调用失败了。我正在运行CentOS 6.3 64位。

Program received signal SIGBUS, Bus error.
0x0000003cfc6175de in strcpy () from /lib64/ld-linux-x86-64.so.2
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.149.el6_6.9.x86_64 libgcc-4.4.7-11.el6.x86_64 libstdc++-4.4.7-11.el6.x86_64
(gdb) bt
#0  0x0000003cfc6175de in strcpy () from /lib64/ld-linux-x86-64.so.2
#1  0x0000003cfc6090b2 in _dl_load_cache_lookup () from /lib64/ld-linux-x86-64.so.2
#2  0x0000003cfc608612 in _dl_map_object () from /lib64/ld-linux-x86-64.so.2
#3  0x0000003cfc612b05 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#4  0x0000003cfc60e266 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#5  0x0000003cfc6125aa in _dl_open () from /lib64/ld-linux-x86-64.so.2
#6  0x0000003cfca00f66 in dlopen_doit () from /lib64/libdl.so.2
#7  0x0000003cfc60e266 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#8  0x0000003cfca0129c in _dlerror_run () from /lib64/libdl.so.2
#9  0x0000003cfca00ee1 in dlopen@@GLIBC_2.2.5 () from /lib64/libdl.so.2
#10 0x00000000004b4425 in my_open_dbus_func (f_name=0x558f2d "libdbus-glib-1.so.2")

我试着用这两行写一个简单的程序,它工作得很好:

void * h = dlopen( "libdbus-glib-1.so.2", RTLD_LAZY );
dlclose( h );

我也试着在valgrind下运行我的原始应用程序,它没有任何问题。

任何帮助/指示都非常感谢。

检查dlopen后面的h是否为NULL。我可以假设dlclose可能崩溃与NULL指针作为参数给定。

似乎其中一个静态库(来自第三方供应商)正在进行可疑的内存管理,这在某种程度上导致我的开放调用崩溃。代码是用来删除虚拟环境的。这个问题可以很容易地在valgrind上检测到,但如果应用程序在valgrind下运行,第三方库将采用不同的代码路径(考虑到valgrind是物理机)

不幸的是,我不知道他们在他们的静态库中固定了什么,但它似乎有效。我写下这个答案(并接受它)是为了避免进一步的混乱。