为什么C Pthread自行退出而没有过程崩溃
why c++ pthread exited by itself without process crash?
我有一个使用近16个线程的过程。线程ID的工作时间在工作后自行退出(请注意过程没有崩溃)。我不确定如何寻找线程退出的原因?我尝试使用打印语句,但这似乎无济于事。尝试通过GDB捕获没有帮助。如果这是某种内存损坏,那么该过程应该崩溃,并且核心文件应该告诉所有内容(大多数时候),但是过程仍在运行,只是线程使我的工作变得困难。
您可以建议某种方法来调试此问题吗?
-arpit
我不确定如何寻找线程退出的原因
我只能想到两种方法:
- 线程函数返回
- 线程函数调用的某些东西执行
syscall(SYS_exit, ...)
您可以使用(gdb) catch syscall exit
,然后可以使用where
来找出发生的事情。
如果where
显示与此相似的东西:
(gdb) where
#0 0x00007ffff7bc3556 in __exit_thread () at ../sysdeps/unix/sysv/linux/exit-thread.h:36
#1 start_thread (arg=0x7ffff781c700) at pthread_create.c:478
#2 0x00007ffff7905a8f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
然后您有案例1,您需要逐步浏览线程功能以找出返回的位置(https://rr-project.org/可能会有很大帮助)。
如果您看到这样的东西:
(gdb) where
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x0000555555554746 in do_work () at t.c:9
#2 0x0000555555554762 in fn (p=0x0) at t.c:15
#3 0x00007ffff7bc3494 in start_thread (arg=0x7ffff781c700) at pthread_create.c:333
#4 0x00007ffff7905a8f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
那么罪魁祸首是任何常规的syscall
。
相关文章:
- 当回溯以零开始时,如何调试崩溃
- 递归函数计算序列中的平方和(并输出过程)
- 内联映射初始化的动态atexit析构函数崩溃
- 执行函数时导致崩溃的变量
- 程序崩溃并显示"std::out_of_range"错误
- CoInitialize()在单独的线程上崩溃而不返回
- 使用调试/崩溃报告将应用程序部署到客户端
- QT在跑步过程中崩溃
- 当过程崩溃时,如何发布boost :: intercess :: ness_mutex
- 在过程中注入性病功能后崩溃
- 如何在启动过程中崩溃时使用 gdb 调试可执行文件
- 尝试从另一个过程读取32位整数时,ReadProcessMemory崩溃了
- 为什么C Pthread自行退出而没有过程崩溃
- 这是实施过程间生产者消费者对流程崩溃的正确和安全的实施
- 当托管它崩溃的可执行过程时,全局挂钩会发生什么
- 如何在程序崩溃后释放managedsharedmemory:在调试过程中使用哪些有效的技术
- 写文件过程崩溃!关闭
- 我应该通过单独的过程编写自己的崩溃转储还是依赖WER
- 调用指向windows过程中C函数的函数的成员指针会导致应用程序崩溃
- visual String使用c++中的指针进行复制,在复制过程中程序崩溃