dlopen 崩溃(接收 SIGBUS)

标签 c linux dbus dlopen

我的一个应用程序因 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 下运行我原来的应用程序,它没有任何问题。

非常感谢任何帮助/指点。

最佳答案

尝试在dlopen之后检查h是否不为NULL。我可以假设 dlclose 可能会因作为参数给出的 NULL 指针而崩溃。

关于dlopen 崩溃(接收 SIGBUS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31544567/

相关文章:

java - 无法通过套接字连接到linux机器

.net - 如何在 Linux 下使用 Mono 运行我的 C# Visual Studio 应用程序?

linux - 原子地调用 pthread_mutex_init

python - 让信号在 PulseAudio 的 DBus 接口(interface)上工作?

python - D-Bus python PyQt5 服务示例

c - WinAPI 命名管道位置

c - 如何通过两个函数处理返回值

c++ - 在 CPU 上并行减少数组

c - 通过 Shaker 排序对数组的主对角线进行排序

python - dbus-python 如何返回字典数组