gpt4 book ai didi

c - 进程线程被 __pthread_enable_asynccancel () 卡住

转载 作者:行者123 更新时间:2023-11-30 15:06:10 25 4
gpt4 key购买 nike

我正在 CentOS 平台上调试多线程 TCP 服务器应用程序的问题。应用程序突然停止处理连接。甚至在日志文件中也看不到使用 syslog 进行的事件记录。就好像应用程序变成了一个黑洞。

我用信号 11 终止了进程以获取核心转储。在核心转储中,我观察到所有线程都陷入相似的模式。

例如:

Thread 19 (Thread 0xb2de8b70 (LWP 3722)):
#0 0x00c9e424 in __kernel_vsyscall ()
#1 0x00c17189 in __pthread_enable_asynccancel () from /lib/libpthread.so.0
#2 0x080b367d in server_debug_stats_timer_handler (tmp=0x0) at server_debug_utils.c:75 ==> this line as a event print with syslog(...)

几乎所有线程都在尝试 syslog(...) 打印,但被 __pthread_enable_asynccancel () 卡住。

__pthread_enable_asynccancel () 正在做什么以及为什么它没有返回?

这是来自提到的线程的信息注册:

(gdb) info reg
eax 0xfffffe00 -512
ecx 0x80 128
edx 0x2 2
ebx 0x154ea3c4 357475268
esp 0xb2de8174 0xb2de8174
ebp 0xb2de81a8 0xb2de81a8
esi 0x0 0
edi 0x0 0
eip 0xc9e424 0xc9e424 <__kernel_vsyscall+16>
eflags 0x200246 [ PF ZF IF ID ]
cs 0x73 115
ss 0x7b 123
ds 0x7b 123
es 0x7b 123
fs 0x0 0
gs 0x33 51
(gdb)

(gdb) print $orig_eax
$1 = 240

($orig_eax = 240SYS_futex)

其中一个线程状态如下图:

    Thread 27 (Thread 0xa97d9b70 (LWP 3737)):
#0 0x00c9e424 in __kernel_vsyscall ()
#1 0x00faabb3 in inet_ntop () from /lib/libc.so.6
#2 0x00f20e76 in freopen64 () from /lib/libc.so.6
#3 0x00f96a55 in fcvt_r () from /lib/libc.so.6
#4 0x00f96fd7 in qfcvt_r () from /lib/libc.so.6
#5 0x00a19932 in app_signal_handler (signum=11) at appBaseClass.cpp:920
#6 <signal handler called>
#7 0x00f2aec5 in sYSMALLOc () from /lib/libc.so.6
#8 0x0043431a in CRYPTO_free () from /usr/local/lr/packages/stg_app/5.3.8/lib/ssl/libcrypto.so.10
#9 0x00000000 in ?? ()

(gdb) print $orig_eax $5 = 240`

最佳答案

您的卡住线程位于 futex() 系统调用中,可能位于 malloc() 内获取的内部 glibc 锁(syslog()) > 调用在内部分配内存)。

造成这种僵局的原因尚不清楚,但我有两个建议:

  • 如果您从程序中任何位置的信号处理程序调用 syslog() (或任何其他非 AS 安全函数,例如 printf()) ,这可能会导致这样的死锁;

  • 您可能被 bug in futex() 咬了这是在 Linux 3.14 中引入并在 3.18 中修复的。该错误也被向后移植到 RHEL 6.6,因此在 CentOS 中也会存在一段时间。此错误的影响是导致进程在应该从 FUTEX_WAIT 中唤醒时失败。

关于c - 进程线程被 __pthread_enable_asynccancel () 卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39398660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com