From: mame@... Date: 2019-12-03T15:58:51+00:00 Subject: [ruby-core:96087] [Ruby master Bug#10495] Attaching lldb to a program running `sleep` hangs the VM Issue #10495 has been updated by mame (Yusuke Endoh). Status changed from Open to Closed I tried the process on Ubuntu, but I couldn't reproduce the issue. Maybe it is already fixed? Tentatively closing. Let me know if you still see the issue. AFAIK there is no committer that daily uses `lldb` for ruby. Contribution is welcome. ---------------------------------------- Bug #10495: Attaching lldb to a program running `sleep` hangs the VM https://bugs.ruby-lang.org/issues/10495#change-82940 * Author: cesario (Franck Verrot) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.2.0dev (2014-10-19 trunk 48023) [x86_64-darwin13] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- Here's the bit of Ruby code: `loop do sleep 1 puts 1 end` Here's the lldb session: `(lldb) attach 41619 Process 41619 stopped (lldb) c Process 41619 resuming Process 41619 stopped * thread #1: tid = 0x75fd5, 0x00007fff89f56716 libsystem_kernel.dylib`__psynch_cvwait + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP frame #0: 0x00007fff89f56716 libsystem_kernel.dylib`__psynch_cvwait + 10 libsystem_kernel.dylib`__psynch_cvwait + 10: -> 0x7fff89f56716: jae 0x7fff89f56720 ; __psynch_cvwait + 20 0x7fff89f56718: movq %rax, %rdi 0x7fff89f5671b: jmpq 0x7fff89f53175 ; cerror_nocancel 0x7fff89f56720: ret (lldb) p (int)rb_eval_string("puts 1") (int) $0 = 8 (lldb) c Process 41619 resuming Process 41619 stopped * thread #1: tid = 0x75fd5, 0x00007fff89f56716 libsystem_kernel.dylib`__psynch_cvwait + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP frame #0: 0x00007fff89f56716 libsystem_kernel.dylib`__psynch_cvwait + 10 libsystem_kernel.dylib`__psynch_cvwait + 10: -> 0x7fff89f56716: jae 0x7fff89f56720 ; __psynch_cvwait + 20 0x7fff89f56718: movq %rax, %rdi 0x7fff89f5671b: jmpq 0x7fff89f53175 ; cerror_nocancel 0x7fff89f56720: ret (lldb) bt * thread #1: tid = 0x75fd5, 0x00007fff89f56716 libsystem_kernel.dylib`__psynch_cvwait + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP * frame #0: 0x00007fff89f56716 libsystem_kernel.dylib`__psynch_cvwait + 10 frame #1: 0x00007fff962c0c3b libsystem_pthread.dylib`_pthread_cond_wait + 727 frame #2: 0x000000010a0d8f82 ruby`gvl_acquire_common + 146 frame #3: 0x000000010a0d1880 ruby`native_sleep + 464 frame #4: 0x000000010a0d24dc ruby`sleep_timeval + 268 frame #5: 0x000000010a016cd4 ruby`rb_f_sleep + 52 frame #6: 0x000000010a0ca02b ruby`vm_call_cfunc + 987 frame #7: 0x000000010a0b31db ruby`vm_exec_core + 10155 frame #8: 0x000000010a0c04af ruby`vm_exec + 127 frame #9: 0x000000010a0c5a11 ruby`loop_i + 49 frame #10: 0x0000000109f9b432 ruby`rb_rescue2 + 274 frame #11: 0x000000010a0bef73 ruby`rb_f_loop + 51 frame #12: 0x000000010a0ca02b ruby`vm_call_cfunc + 987 frame #13: 0x000000010a0c9970 ruby`vm_call_method + 848 frame #14: 0x000000010a0b3033 ruby`vm_exec_core + 9731 frame #15: 0x000000010a0c04af ruby`vm_exec + 127 frame #16: 0x000000010a0c1398 ruby`rb_iseq_eval_main + 392 frame #17: 0x0000000109f9a8a4 ruby`ruby_exec_internal + 148 frame #18: 0x0000000109f9a7ce ruby`ruby_run_node + 78 frame #19: 0x0000000109f5c4ef ruby`main + 79` TL;DR : I'm asking Ruby to eval "puts 1". AFAICT, `gvl_acquire_common` that calls pthread's `native_sleep`/`pthread_cond_wait` never wakes up. But, if I don't call `puts` (which would be, within lldb, equivalent to 'p (int)rb_eval_string("1")', the thread will continue running normally. Please let me know if any info's missing. Thanks in advance, Franck -- https://bugs.ruby-lang.org/ Unsubscribe: