调用dlopen的库中入存在线程,则调用dlclose会出现segmentation fault

K_s_G 2013-10-18 11:44:13
RT

若dlopen打开的库中不存在线程,或线程不在运行状态,则调用dlclose时,不会死机;
若存在运行时的线程,则dlclose时出现segmentation fault。
编译选项入下:
gcc -o main -lpthread -ldl main.c
gcc -g -rdynamic -shared -fPIC -o libtest.so test.c

求解!

...全文
777 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
nonths 2014-04-04
  • 打赏
  • 举报
回复
哥们解决没有?我遇到和你一样的问题,我用dlopen代开的库没有开启任何线程,但是dlclose的时候也会crash,很纠结
K_s_G 2013-10-18
  • 打赏
  • 举报
回复
gdb调试,堆栈如下: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1219175536 (LWP 32698)] 0x0041a658 in ?? () (gdb) bt #0 0x0041a658 in ?? () #1 0x00000005 in ?? () #2 0x0075aff4 in ?? () from /lib/libpthread.so.0 #3 0xb754d4b8 in ?? () #4 0x0074c3db in start_thread () from /lib/libpthread.so.0 #5 0x0074c3db in start_thread () from /lib/libpthread.so.0 #6 0x006a606e in clone () from /lib/libc.so.6 (gdb) info threads * 3 Thread -1219175536 (LWP 32698) 0x0041a658 in ?? () 2 Thread -1208685680 (LWP 32697) 0x00c93402 in __kernel_vsyscall () 1 Thread -1208681792 (LWP 32694) 0x00c93402 in __kernel_vsyscall () (gdb)
Wenxy1 2013-10-18
  • 打赏
  • 举报
回复
用gdb调试吧。

23,216

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧