You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Segfault when exiting due to Fiddle::MemoryView #79
The following script causes a segfault when exiting:
$workaround = false
require 'fiddle'
Fiddle::MemoryView.new(Fiddle::Pointer["foo"])
GC.start if $workaround
A backtrace from GDB:
Thread 1 received signal SIGSEGV, Segmentation fault.
rb_class_get_superclass (klass=klass@entry=0) at ../object.c:2252
2252 return RCLASS(klass)->super;
(gdb) bt
#0 rb_class_get_superclass (klass=klass@entry=0) at ../object.c:2252
#1 0x0000000589c03ae3 in lookup_memory_view_entry (klass=0) at ../memory_view.c:784
#2 0x0000000589c04921 in rb_memory_view_release (view=view@entry=0x800157770) at ../memory_view.c:836
#3 0x0000000596513c13 in fiddle_memview_free (ptr=0x800157770) at ../../../ext/fiddle/memory_view.c:41
#4 0x0000000589bd9226 in run_final (zombie=123145300985120, objspace=0x800052bc0) at ../gc.c:4040
#5 finalize_list (objspace=objspace@entry=0x800052bc0, zombie=123145300985120) at ../gc.c:4059
#6 0x0000000589bdd6e1 in rb_objspace_call_finalizer (objspace=0x800052bc0) at ../gc.c:4222
#7 0x0000000589bc5f37 in rb_ec_finalize (ec=ec@entry=0x800053520) at ../eval.c:187
#8 0x0000000589bc8e25 in rb_ec_cleanup (ec=ec@entry=0x800053520, ex=<optimized out>) at ../eval.c:298
#9 0x0000000589bc8fa8 in ruby_run_node (n=0x6fffffed3068) at ../eval.c:379
#10 0x00000001004017ad in main (argc=<optimized out>, argv=<optimized out>) at ../main.c:47
Invoking a GC before exiting seems to be a workaround.
Activity
Add MemoryView.get and MemoryView#release
mrkn commentedon Jun 17, 2021
I guess this SEGV is a bug of
rb_memory_view_release.Add MemoryView.export and MemoryView#release (#80)
kou commentedon Jun 17, 2021
I think that this isn't avoidable without improving Ruby's GC on exit but I' reopen this to wait @mrkn's investigation.
kou commentedon Jun 17, 2021
#80 can be used instead of
GC.start.[ruby/fiddle] Add MemoryView.export and MemoryView#release (ruby/fidd…