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 in FFI::Struct#[] after GC.compact #742
Comments
It turned out that issue is easily reproducible when require "ffi"
class St < FFI::Struct
layout :i, :int
end
s = St.new
p GC.verify_compaction_references(toward: :empty, double_heap: true)[:moved]
s[:i] Fails with: lars@isa:~/comcard/ffi$ git:(master) 1M 13A ruby test-gc-compact.rb
{:T_NONE=>0, :T_OBJECT=>758, :T_CLASS=>509, :T_MODULE=>15, :T_FLOAT=>0, :T_STRING=>8810, :T_REGEXP=>85, :T_ARRAY=>1381, :T_HASH=>85, :T_STRUCT=>11, :T_BIGNUM=>0, :T_FILE=>0, :T_DATA=>103, :T_MATCH=>0, :T_COMPLEX=>0, :T_RATIONAL=>0, 16=>0, :T_NIL=>0, :T_TRUE=>0, :T_FALSE=>0, :T_SYMBOL=>132, :T_FIXNUM=>0, :T_UNDEF=>0, 23=>0, 24=>0, 25=>0, :T_IMEMO=>5074, :T_NODE=>0, :T_ICLASS=>52, :T_ZOMBIE=>0, :T_MOVED=>0}
test-gc-compact.rb:9: [BUG] Segmentation fault at 0x0000000000000028
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0003 p:---- s:0012 e:000011 CFUNC :[]
c:0002 p:0068 s:0007 E:000138 EVAL test-gc-compact.rb:9 [FINISH]
c:0001 p:0000 s:0003 E:001e80 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
test-gc-compact.rb:9:in `<main>'
test-gc-compact.rb:9:in `[]'
-- Machine register context ------------------------------------------------
RIP: 0x00007fdd5f9090b3 RBP: 0x000055cf3b812af0 RSP: 0x00007ffdd1cbb470
RAX: 0x0000000000000001 RBX: 0x000055cf3ba1b4d0 RCX: 0x0000000000000000
RDX: 0x000055cf3b88dec0 RDI: 0x0000000000000000 RSI: 0x000000000026310c
R8: 0x000055cf3b871f08 R9: 0x000000000000001f R10: 0x00007fdd63c9a4f0
R11: 0x00007fdd63ab8b80 R12: 0x000000000026310c R13: 0x000055cf3b812a70
R14: 0x000055cf3ba1b4d0 R15: 0x000055cf3b8c0a20 EFL: 0x0000000000010202
-- C level backtrace information -------------------------------------------
/home/lars/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_vm_bugreport+0x573) [0x7fdd63b51a73] vm_dump.c:755
[0x7fdd63974dab]
/home/lars/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(sigsegv+0x4d) [0x7fdd63aae7cd] signal.c:946
/lib/x86_64-linux-gnu/libc.so.6(0x7fdd636d0470) [0x7fdd636d0470]
/home/lars/.rvm/gems/ruby-2.7.0/gems/ffi-1.12.1/lib/ffi_c.so(struct_aref+0x73) [0x7fdd5f9090b3] Struct.c:317
[0x7fdd63b29b00]
[0x7fdd63b3effb]
[0x7fdd63b3720b]
[0x7fdd63b3db64]
/home/lars/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_ec_exec_node+0xc1) [0x7fdd639798e1] eval.c:277
/home/lars/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(ruby_run_node+0x4e) [0x7fdd6397f1fe] eval.c:335
/home/lars/.rvm/rubies/ruby-2.7.0/bin/ruby(main+0x5f) [0x55cf39b2217f] ./main.c:50 But after commit 6662bcc no segfault occurs any longer. |
This was referenced Oct 23, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original issue: cotag/http-parser#3 (comment)
I was able to trigger the segfault once with ffi-1.12.1. Unfortunately I didn't find a way to reproduce it reliably.
irb input and backtrace
The text was updated successfully, but these errors were encountered: