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

Segfault on Thread #42

Closed
m-zielinski opened this issue Nov 22, 2023 · 2 comments · Fixed by #43
Closed

Segfault on Thread #42

m-zielinski opened this issue Nov 22, 2023 · 2 comments · Fixed by #43

Comments

@m-zielinski
Copy link

m-zielinski commented Nov 22, 2023

Maybe I'm doing smth wrong, but the simplest script with Vernier segfaults for me if I use Thread:

require 'vernier'

Vernier.trace(out: 'profile.json') do
  Thread.new { sleep 1 }.join # works fine without it
end

vernier 0.30
Ruby 3.2.0

[BUG] Segmentation fault at 0x0000000000000020
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]

-- Control frame information -----------------------------------------------


-- Machine register context ------------------------------------------------
 RIP: 0x00007f55ec391de9 RBP: 0x0000000000000800 RSP: 0x00007f55dff305e0
 RAX: 0x0000000000000000 RBX: 0x0000000000000000 RCX: 0x00007f55e6acfe00
 RDX: 0x0000000000000000 RDI: 0x00007f55ec66df90 RSI: 0x0000000000000800
  R8: 0x0000000000000000  R9: 0x0000000000000000 R10: 0x0000000000000000
 R11: 0x0000000000000286 R12: 0x0000000000000000 R13: 0xffffffffffffffc0
 R14: 0x00007f55e6acfe00 R15: 0x0000000000000000 EFL: 0x0000000000010203

-- C level backtrace information -------------------------------------------
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(rb_print_backtrace+0x11) [0x7f55ec393bd4] vm_dump.c:785
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(rb_vm_bugreport) vm_dump.c:1080
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(rb_bug_for_fatal_signal+0xf4) [0x7f55ec18da74] error.c:813
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(sigsegv+0x4d) [0x7f55ec2e5e7d] signal.c:964
/lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7f55ebe7f420]
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(VM_ENV_FLAGS+0x0) [0x7f55ec391de9] vm_backtrace.c:1586
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(VM_FRAME_CFRAME_P) vm_core.h:1341
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(VM_FRAME_RUBYFRAME_P) vm_core.h:1350
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(rb_profile_frames) vm_backtrace.c:1587
/home/marek/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/vernier-0.3.0/lib/vernier/vernier.so(0x7f55e6d03272) [0x7f55e6d03272]
/home/marek/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/vernier-0.3.0/lib/vernier/vernier.so(_ZN19GlobalSignalHandler14signal_handlerEiP9siginfo_tPv) (null):0
/lib/x86_64-linux-gnu/libpthread.so.0(__restore_rt+0x0) [0x7f55ebe7f420]
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(thread_start_func_2+0x1f7) [0x7f55ec332be7] thread.c:676
/home/marek/.rbenv/versions/3.2.0/lib/libruby.so.3.2(thread_start_func_1+0xf0) [0x7f55ec3339d0] thread_pthread.c:1170
/lib/x86_64-linux-gnu/libpthread.so.0(start_thread+0xd9) [0x7f55ebe73609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7f55ebd98133]
@casperisfine
Copy link
Contributor

You are using Ruby 3.2.0, which has a "bug" in rb_profile_frame: https://github.com/tmm1/stackprof/blob/91d12e77b3d3c5014870b4ee7c19eab24ad04b5b/lib/stackprof.rb#L13-L18

It may crash when called asynchronously.

Try upgrading to 3.2.2.

@m-zielinski
Copy link
Author

m-zielinski commented Nov 22, 2023

Thank you! It works with ruby 3.2.2 (also 3.2.1).
Maybe it's worth mentioning in the readme or even gemspec...?

casperisfine added a commit to casperisfine/vernier that referenced this issue Nov 22, 2023
3.2.0 has a bug that cause `rb_profile_frames` to not be async signal safe: ruby/ruby#7116

It has been backported in 3.2.1, so might as well prevent the installation of the gem.

Fix: jhawthorn#42
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

Successfully merging a pull request may close this issue.

2 participants