碰撞在dlopen(接收SIGBUS)

我的一个应用程序因为SIGBUS信号而崩溃。 以下是gdb的堆栈跟踪。 基本上,dlopen电话是失败的。 我正在运行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下运行我的原始应用程序,它没有任何问题。

任何帮助/指针真的很感激。

看起来静态库(来自第三方vedor)之一正在做阴暗的内存管理,这导致我的dlopen电话崩溃。 编写代码来确定虚拟环境。 在valgrind上可以很容易的发现问题,但是如果应用程序在valgrind下运行,第三方库会采用不同的代码路径(考虑到valgrind是物理机器)

不幸的是,我不知道他们在静态库中修复了什么,但它似乎工作。 我正在写这个答案(并接受它),以避免进一步的混乱。

尝试检查dlopen之后h是否不为NULL。 我可能会认为dlclose可能会崩溃与一个NULL指针作为参数给出。