Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhouyuyu888 opened this issue Jan 4, 2024 · 2 comments

Comments

@zhouyuyu888
Copy link

zhouyuyu888 commented Jan 4, 2024

运行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
Copy link

zhouyunbin commented Jan 4, 2024 via email

@philGemini
Copy link

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

rotater.c 大约 461 行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants