我的一个应用程序因为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 );我还试着运行我最初的应用程序,它没有任何问题。
任何帮助/指示都是非常感谢的。
发布于 2016-01-08 20:20:42
似乎有一个静态库(来自第三方维多)正在进行可疑内存管理,这导致了我的dlopen调用崩溃。编写代码是为了删除虚拟环境。这个问题本可以很容易地检测到,但是如果应用程序运行在val差制下,第三方库将采用不同的代码路径(考虑到val差事是物理机器)。
不幸的是,我不知道他们在他们的静态库中固定了什么,但它似乎起作用了。我写这个答案(并接受它)是为了避免进一步的混乱。
发布于 2016-01-08 08:24:59
尝试检查h在dlopen之后是否为NULL。我可能假设dlclose可能会使用作为参数的空指针崩溃。
https://stackoverflow.com/questions/31544567
复制相似问题