From: takashikkbn@... Date: 2019-04-02T03:01:43+00:00 Subject: [ruby-core:92100] [Ruby trunk Bug#15737] Queue#pop randomly hangs forever Issue #15737 has been updated by k0kubun (Takashi Kokubun). Assignee changed from normalperson (Eric Wong) to ko1 (Koichi Sasada) ---------------------------------------- Bug #15737: Queue#pop randomly hangs forever https://bugs.ruby-lang.org/issues/15737#change-77428 * Author: k0kubun (Takashi Kokubun) * Status: Open * Priority: Normal * Assignee: ko1 (Koichi Sasada) * Target version: * ruby -v: ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- With Ruby 2.6, my single-worker application https://github.com/k0kubun/ruboty sometimes stops to respond to a message. `rb_queue_pop` does not seem to be waken up in `rb_sigwait_sleep` in some condition. ``` strace: Process 18699 attached ppoll([{fd=3, events=POLLIN}], 1, NULL, NULL, 8^Cstrace: Process 18699 detached k0kubun@kubernetes-master:~$ sudo gdb -p 18699 GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". Attaching to process 18699 [New LWP 18751] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". warning: Target and debugger are in different PID namespaces; thread lists and other data are likely unreliable. Connect to gdbserver inside the container. 0x00007f3f8f341cf6 in __GI_ppoll (fds=fds@entry=0x7fff91524e18, nfds=nfds@entry=1, timeout=, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39 39 ../sysdeps/unix/sysv/linux/ppoll.c: No such file or directory. (gdb) info threads (gdb) info threads Id Target Id Frame * 1 Thread 0x7f3f9088e780 (LWP 18699) "bundle" 0x00007f3f8f341cf6 in __GI_ppoll (fds=fds@entry=0x7fff91524e18, nfds=nfds@entry=1, timeout=, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39 2 Thread 0x7f3f8bdf5700 (LWP 18751) "client.rb:65" 0x00007f3f90243ed9 in futex_reltimed_wait_cancelable (private=, reltime=0x7f3f8bdf3f20, expected=0, futex_word=0x7f3f86701f94) at ../sysdeps/unix/sysv/linux/futex-internal.h:142 (gdb) bt #0 0x00007f3f8f341cf6 in __GI_ppoll (fds=fds@entry=0x7fff91524e18, nfds=nfds@entry=1, timeout=, sigmask=sigmask@entry=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39 #1 0x00005589562a1af7 in rb_sigwait_sleep (th=th@entry=0x7f3f8e80f080, sigwait_fd=sigwait_fd@entry=3, rel=rel@entry=0x0) at thread_pthread.c:2039 #2 0x00005589562a4ee6 in native_sleep (th=, rel=0x0) at thread_pthread.c:2159 #3 0x00005589562a54f9 in queue_sleep () at hrtime.h:85 #4 0x0000558956140eb3 in rb_ensure (b_proc=b_proc@entry=0x5589562a5470 , data1=data1@entry=139910854015840, e_proc=e_proc@entry=0x55895629bd80 , data2=data2@entry=140735631478912) at eval.c:1075 #5 0x000055895629ecbb in queue_do_pop (should_block=1, q=, self=139910854015840) at thread_sync.c:909 #6 rb_queue_pop (argc=, argv=, self=139910854015840) at thread_sync.c:945 #7 0x00005589562dbf3a in vm_call_cfunc_with_frame (ci=0x7f3f8a545a00, cc=, calling=, reg_cfp=0x7f3f8e9589a8, ec=0x7f3f8e850348) at vm_insnhelper.c:1908 #8 vm_call_cfunc (ec=0x7f3f8e850348, reg_cfp=0x7f3f8e9589a8, calling=, ci=0x7f3f8a545a00, cc=) at vm_insnhelper.c:1924 #9 0x00005589562e7e33 in vm_call_method (ec=0x7f3f8e850348, cfp=0x7f3f8e9589a8, calling=, ci=, cc=) at vm_insnhelper.c:2397 #10 0x00005589562edf9f in vm_exec_core (ec=ec@entry=0x7f3f8e850348, initial=initial@entry=0) at insns.def:765 #11 0x00005589562e437c in rb_vm_exec (ec=ec@entry=0x7f3f8e850348, mjit_enable_p=mjit_enable_p@entry=1) at vm.c:1885 #12 0x00005589562f5b71 in invoke_block (captured=, opt_pc=, type=, cref=0x0, self=, iseq=, ec=0x7f3f8e850348) at vm.c:1021 #13 invoke_iseq_block_from_c (me=0x0, is_lambda=, cref=0x0, passed_block_handler=0, argv=0x0, argc=0, self=, captured=, ec=0x7f3f8e850348) at vm.c:1092 #14 invoke_block_from_c_bh (argc=, argv=, passed_block_handler=, cref=, is_lambda=, force_blockarg=, block_handler=, ec=) at vm.c:1110 #15 vm_yield (argc=0, argv=0x0, ec=0x7f3f8e850348) at vm.c:1155 #16 rb_yield_0 (argv=0x0, argc=0) at vm_eval.c:978 #17 loop_i () at vm_eval.c:1057 #18 0x00005589561408bf in rb_rescue2 (b_proc=0x5589562f58a0 , data1=0, r_proc=0x5589562d72a0 , data2=0) at eval.c:934 #19 0x00005589562dbf3a in vm_call_cfunc_with_frame (ci=0x7f3f8a598950, cc=, calling=, reg_cfp=0x7f3f8e958a18, ec=0x7f3f8e850348) at vm_insnhelper.c:1908 #20 vm_call_cfunc (ec=0x7f3f8e850348, reg_cfp=0x7f3f8e958a18, calling=, ci=0x7f3f8a598950, cc=) at vm_insnhelper.c:1924 #21 0x00005589562e7e33 in vm_call_method (ec=0x7f3f8e850348, cfp=0x7f3f8e958a18, calling=, ci=, cc=) at vm_insnhelper.c:2397 #22 0x00005589562ee043 in vm_exec_core (ec=ec@entry=0x7f3f8e850348, initial=initial@entry=0) at insns.def:750 #23 0x00005589562e437c in rb_vm_exec (ec=ec@entry=0x7f3f8e850348, mjit_enable_p=mjit_enable_p@entry=1) at vm.c:1885 #24 0x00005589562f5b71 in invoke_block (captured=, opt_pc=, type=, cref=0x0, self=, iseq=, ec=0x7f3f8e850348) at vm.c:1021 #25 invoke_iseq_block_from_c (me=0x0, is_lambda=, cref=0x0, passed_block_handler=0, argv=0x0, argc=0, self=, captured=, ec=0x7f3f8e850348) at vm.c:1092 #26 invoke_block_from_c_bh (argc=, argv=, passed_block_handler=, cref=, is_lambda=, force_blockarg=, block_handler=, ec=) at vm.c:1110 #27 vm_yield (argc=0, argv=0x0, ec=0x7f3f8e850348) at vm.c:1155 #28 rb_yield_0 (argv=0x0, argc=0) at vm_eval.c:978 #29 loop_i () at vm_eval.c:1057 #30 0x00005589561408bf in rb_rescue2 (b_proc=0x5589562f58a0 , data1=0, r_proc=0x5589562d72a0 , data2=0) at eval.c:934 ---Type to continue, or q to quit--- #31 0x00005589562dbf3a in vm_call_cfunc_with_frame (ci=0x7f3f8a56fa90, cc=, calling=, reg_cfp=0x7f3f8e958ac0, ec=0x7f3f8e850348) at vm_insnhelper.c:1908 #32 vm_call_cfunc (ec=0x7f3f8e850348, reg_cfp=0x7f3f8e958ac0, calling=, ci=0x7f3f8a56fa90, cc=) at vm_insnhelper.c:1924 #33 0x00005589562e7e33 in vm_call_method (ec=0x7f3f8e850348, cfp=0x7f3f8e958ac0, calling=, ci=, cc=) at vm_insnhelper.c:2397 #34 0x00005589562ee043 in vm_exec_core (ec=0x7f3f8e850348, initial=initial@entry=0) at insns.def:750 #35 0x00005589562e499f in rb_vm_exec (ec=0x7f3f8e850348, mjit_enable_p=mjit_enable_p@entry=1) at vm.c:1894 #36 0x00005589562f5fa1 in rb_iseq_eval (iseq=iseq@entry=0x7f3f8bbb32b8) at vm.c:2133 #37 0x0000558956193787 in rb_load_internal0 (ec=ec@entry=0x7f3f8e850348, fname=fname@entry=139910903970800, wrap=) at load.c:612 #38 0x0000558956193a50 in rb_load_internal (wrap=0, fname=139910903970800) at load.c:643 #39 rb_f_load (argc=, argv=) at load.c:711 #40 0x00005589562dbf3a in vm_call_cfunc_with_frame (ci=0x7f3f8bb07d80, cc=, calling=, reg_cfp=0x7f3f8e958c48, ec=0x7f3f8e850348) at vm_insnhelper.c:1908 #41 vm_call_cfunc (ec=0x7f3f8e850348, reg_cfp=0x7f3f8e958c48, calling=, ci=0x7f3f8bb07d80, cc=) at vm_insnhelper.c:1924 #42 0x00005589562e7e33 in vm_call_method (ec=0x7f3f8e850348, cfp=0x7f3f8e958c48, calling=, ci=, cc=) at vm_insnhelper.c:2397 #43 0x00005589562edf9f in vm_exec_core (ec=ec@entry=0x7f3f8e850348, initial=initial@entry=0) at insns.def:765 #44 0x00005589562e437c in rb_vm_exec (ec=0x7f3f8e850348, mjit_enable_p=mjit_enable_p@entry=1) at vm.c:1885 #45 0x00005589562f5fa1 in rb_iseq_eval (iseq=iseq@entry=0x7f3f8bb73b68) at vm.c:2133 #46 0x0000558956193787 in rb_load_internal0 (ec=ec@entry=0x7f3f8e850348, fname=fname@entry=139910903678960, wrap=) at load.c:612 #47 0x0000558956193a50 in rb_load_internal (wrap=0, fname=139910903678960) at load.c:643 #48 rb_f_load (argc=, argv=) at load.c:711 #49 0x00005589562dbf3a in vm_call_cfunc_with_frame (ci=0x7f3f8b98cc30, cc=, calling=, reg_cfp=0x7f3f8e958cb8, ec=0x7f3f8e850348) at vm_insnhelper.c:1908 #50 vm_call_cfunc (ec=0x7f3f8e850348, reg_cfp=0x7f3f8e958cb8, calling=, ci=0x7f3f8b98cc30, cc=) at vm_insnhelper.c:1924 #51 0x00005589562e7e33 in vm_call_method (ec=0x7f3f8e850348, cfp=0x7f3f8e958cb8, calling=, ci=, cc=) at vm_insnhelper.c:2397 #52 0x00005589562edf9f in vm_exec_core (ec=0x7f3f8e850348, initial=initial@entry=0) at insns.def:765 #53 0x00005589562e499f in rb_vm_exec (ec=0x7f3f8e850348, mjit_enable_p=mjit_enable_p@entry=1) at vm.c:1894 #54 0x00005589562f5fa1 in rb_iseq_eval (iseq=iseq@entry=0x7f3f8c040420) at vm.c:2133 #55 0x0000558956193787 in rb_load_internal0 (ec=ec@entry=0x7f3f8e850348, fname=fname@entry=139910909116680, wrap=) at load.c:612 #56 0x0000558956193a50 in rb_load_internal (wrap=0, fname=139910909116680) at load.c:643 #57 rb_f_load (argc=, argv=) at load.c:711 #58 0x00005589562dbf3a in vm_call_cfunc_with_frame (ci=0x7f3f8c187700, cc=, calling=, reg_cfp=0x7f3f8e958f90, ec=0x7f3f8e850348) at vm_insnhelper.c:1908 #59 vm_call_cfunc (ec=0x7f3f8e850348, reg_cfp=0x7f3f8e958f90, calling=, ci=0x7f3f8c187700, cc=) at vm_insnhelper.c:1924 #60 0x00005589562e7e33 in vm_call_method (ec=0x7f3f8e850348, cfp=0x7f3f8e958f90, calling=, ci=, cc=) at vm_insnhelper.c:2397 #61 0x00005589562edf9f in vm_exec_core (ec=0x7f3f8e850348, initial=initial@entry=0) at insns.def:765 #62 0x00005589562e499f in rb_vm_exec (ec=0x7f3f8e850348, mjit_enable_p=mjit_enable_p@entry=1) at vm.c:1894 #63 0x00005589562f60ba in rb_iseq_eval_main (iseq=iseq@entry=0x7f3f8c1960e0) at vm.c:2144 #64 0x000055895613b0f3 in ruby_exec_internal (n=0x7f3f8c1960e0) at eval.c:261 #65 0x000055895613fe6b in ruby_exec_node (n=) at eval.c:325 #66 ruby_run_node (n=) at eval.c:317 #67 0x000055895613adeb in main (argc=, argv=) at ./main.c:42 (gdb) (gdb) thread 2 [Switching to thread 2 (Thread 0x7f3f8bdf5700 (LWP 18751))] #0 0x00007f3f90243ed9 in futex_reltimed_wait_cancelable (private=, reltime=0x7f3f8bdf3f20, expected=0, futex_word=0x7f3f86701f94) at ../sysdeps/unix/sysv/linux/futex-internal.h:142 142 ../sysdeps/unix/sysv/linux/futex-internal.h: No such file or directory. (gdb) bt #0 0x00007f3f90243ed9 in futex_reltimed_wait_cancelable (private=, reltime=0x7f3f8bdf3f20, expected=0, futex_word=0x7f3f86701f94) at ../sysdeps/unix/sysv/linux/futex-internal.h:142 #1 __pthread_cond_wait_common (abstime=0x7f3f8bdf4010, mutex=0x7f3f86701fc0, cond=0x7f3f86701f68) at pthread_cond_wait.c:533 #2 __pthread_cond_timedwait (cond=cond@entry=0x7f3f86701f68, mutex=mutex@entry=0x7f3f86701fc0, abstime=abstime@entry=0x7f3f8bdf4010) at pthread_cond_wait.c:667 #3 0x00005589562a426a in native_cond_timedwait (abs=, mutex=0x7f3f86701fc0, cond=0x7f3f86701f68) at thread_pthread.c:529 #4 native_cond_sleep (th=th@entry=0x7f3f86701f00, rel=rel@entry=0x7f3f8bdf40a0) at thread_pthread.c:1272 #5 0x00005589562a440f in native_sleep (th=0x7f3f86701f00, rel=0x7f3f8bdf40a0) at thread_pthread.c:2173 #6 0x00005589562a5a09 in sleep_hrtime (fl=2, rel=, th=0x7f3f86701f00) at thread.c:1276 #7 rb_thread_wait_for (time=...) at thread.c:1324 #8 0x0000558956207b90 in rb_f_sleep (argc=1, argv=0x7f3f8511b070) at process.c:4832 #9 0x00005589562dbf3a in vm_call_cfunc_with_frame (ci=0x7f3f8a545ca0, cc=, calling=, reg_cfp=0x7f3f8521af20, ec=0x7f3f8657ba48) at vm_insnhelper.c:1908 #10 vm_call_cfunc (ec=0x7f3f8657ba48, reg_cfp=0x7f3f8521af20, calling=, ci=0x7f3f8a545ca0, cc=) at vm_insnhelper.c:1924 #11 0x00005589562edf9f in vm_exec_core (ec=ec@entry=0x7f3f8657ba48, initial=initial@entry=0) at insns.def:765 #12 0x00005589562e437c in rb_vm_exec (ec=ec@entry=0x7f3f8657ba48, mjit_enable_p=mjit_enable_p@entry=1) at vm.c:1885 #13 0x00005589562f5b71 in invoke_block (captured=, opt_pc=, type=, cref=0x0, self=, iseq=, ec=0x7f3f8657ba48) at vm.c:1021 #14 invoke_iseq_block_from_c (me=0x0, is_lambda=, cref=0x0, passed_block_handler=0, argv=0x0, argc=0, self=, captured=, ec=0x7f3f8657ba48) at vm.c:1092 #15 invoke_block_from_c_bh (argc=, argv=, passed_block_handler=, cref=, is_lambda=, force_blockarg=, block_handler=, ec=) at vm.c:1110 #16 vm_yield (argc=0, argv=0x0, ec=0x7f3f8657ba48) at vm.c:1155 #17 rb_yield_0 (argv=0x0, argc=0) at vm_eval.c:978 #18 loop_i () at vm_eval.c:1057 #19 0x00005589561408bf in rb_rescue2 (b_proc=0x5589562f58a0 , data1=0, r_proc=0x5589562d72a0 , data2=0) at eval.c:934 #20 0x00005589562dbf3a in vm_call_cfunc_with_frame (ci=0x7f3f8a6072e0, cc=, calling=, reg_cfp=0x7f3f8521af90, ec=0x7f3f8657ba48) at vm_insnhelper.c:1908 #21 vm_call_cfunc (ec=0x7f3f8657ba48, reg_cfp=0x7f3f8521af90, calling=, ci=0x7f3f8a6072e0, cc=) at vm_insnhelper.c:1924 #22 0x00005589562e7e33 in vm_call_method (ec=0x7f3f8657ba48, cfp=0x7f3f8521af90, calling=, ci=, cc=) at vm_insnhelper.c:2397 #23 0x00005589562ee043 in vm_exec_core (ec=ec@entry=0x7f3f8657ba48, initial=initial@entry=0) at insns.def:750 #24 0x00005589562e437c in rb_vm_exec (ec=0x7f3f8657ba48, mjit_enable_p=mjit_enable_p@entry=1) at vm.c:1885 #25 0x00005589562e4dc1 in invoke_block (ec=ec@entry=0x7f3f8657ba48, iseq=iseq@entry=0x7f3f8baee4b8, self=self@entry=139910854015920, cref=cref@entry=0x0, type=type@entry=572653569, opt_pc=0, captured=) at vm.c:1021 #26 0x00005589562e8757 in invoke_iseq_block_from_c (me=0x0, is_lambda=, cref=0x0, passed_block_handler=0, argv=0x7f3f8511b018, argc=0, self=139910854015920, captured=0x7f3f871ed5b0, ec=0x7f3f8657ba48) at vm.c:1092 #27 invoke_block_from_c_proc (me=0x0, is_lambda=, passed_block_handler=0, argv=0x7f3f8511b018, argc=0, self=139910854015920, proc=0x7f3f88c0fbb0, ec=0x7f3f8657ba48) at vm.c:1192 #28 vm_invoke_proc (passed_block_handler=0, argv=0x7f3f8511b018, argc=0, self=139910854015920, proc=0x7f3f88c0fbb0, ec=0x7f3f8657ba48) at vm.c:1210 #29 rb_vm_invoke_proc (ec=0x7f3f8657ba48, proc=proc@entry=0x7f3f871ed5b0, argc=argc@entry=0, argv=argv@entry=0x7f3f8bdf4b90, passed_block_handler=passed_block_handler@entry=0) at vm.c:1231 #30 0x00005589562a1641 in thread_do_start (th=th@entry=0x7f3f86701f00) at thread.c:686 ---Type to continue, or q to quit--- #31 0x00005589562a38c6 in thread_start_func_2 (th=th@entry=0x7f3f86701f00, stack_start=) at thread.c:725 #32 0x00005589562a3ddb in thread_start_func_1 (th_ptr=) at thread_pthread.c:1030 #33 0x00007f3f9023d6db in start_thread (arg=0x7f3f8bdf5700) at pthread_create.c:463 #34 0x00007f3f8f34e88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 (gdb) q A debugging session is active. Inferior 1 [process 18699] will be detached. Quit anyway? (y or n) y Detaching from program: target:/usr/local/bin/ruby, process 18699 ``` -- https://bugs.ruby-lang.org/ Unsubscribe: