HardySimpson / zlog

A reliable, high-performance, thread safe, flexsible, clear-model, pure C logging library.
Apache License 2.0
2.25k stars 720 forks source link

zlog加上轮转,在fork多进程情况下运行几千次还是会死锁 #246

Open zhouyuyu888 opened 10 months ago

zhouyuyu888 commented 10 months ago

运行runtime=9420次后:主进程死锁,子进程进入僵尸 root 24349 24170 52 09:23 pts/0 00:04:07 ./taskc root 25854 24349 0 09:30 pts/0 00:00:00 [taskc] # strace -p 24349结果如下: strace: Process 24349 attached futex(0x7fd20e6195c0, FUTEX_WAIT_PRIVATE, 2, NULL #pstack 24349结果如下:

0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135

1 0x00007fd20e00ba24 in pthread_rwlock_rdlock () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S:122

2 0x00007fd20e412037 in zlog (category=0xa10cd0, file=0x401230 "taskc.c", filelen=7, func=0x401342 <__FUNCTION__.4306> "do_sig_child", funclen=12, line=39, level=30, format=0x401238 "do_sig_child, pid=%d, tid=%d,sigs=%d\n") at zlog.c:1010

3 0x0000000000400c4a in do_sig_child ()

4

5 pthread_rwlock_unlock () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S:41

6 0x00007fd20e412071 in zlog (category=0xa10cd0, file=0x401230 "taskc.c", filelen=7, func=0x40134f <__FUNCTION__.4332> "main", funclen=, line=170, level=30, format=0x401309 "Parent ID %d\n") at zlog.c:1037

7 0x00000000004010f3 in main ()

gcore 后,用gdb /root/taskc core.24349,where结果如下: Core was generated by `./taskc'.

0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135

135 ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: No such file or directory. (gdb) where

0 __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135

1 0x00007fd20e00ba24 in pthread_rwlock_rdlock () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S:122

2 0x00007fd20e412037 in zlog (category=0xa10cd0, file=0x401230 "taskc.c", filelen=7, func=0x401342 <__FUNCTION__.4306> "do_sig_child", funclen=12, line=39,

level=30, format=0x401238 "do_sig_child, pid=%d, tid=%d,sigs=%d\n") at zlog.c:1010

3 0x0000000000400c4a in do_sig_child ()

4

5 pthread_rwlock_unlock () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_unlock.S:41

6 0x00007fd20e412071 in zlog (category=0xa10cd0, file=0x401230 "taskc.c", filelen=7, func=0x40134f <__FUNCTION__.4332> "main", funclen=,

line=170, level=30, format=0x401309 "Parent ID %d\n") at zlog.c:1037

7 0x00000000004010f3 in main ()

zhouyunbin commented 10 months ago

您好,已收到您的来信

philGemini commented 8 months ago

我也发生这个问题了 看了一下代码 似乎是 lock_thread 之后 lock_file 失败就直接返回了 没有解锁导致的 改一下就好

rotater.c 大约 461 行