Projects

Ticket #711 (closed defect: fixed)

Opened 21 months ago

Last modified 21 months ago

MacRuby caught SIGSEGV when call Dispatch::Job#add many times

Reported by: nagachika00@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.7
Component: MacRuby Keywords:
Cc:

Description

When I modify AO Bench script (see #710) to use Dispatch::Job, it caught SIGSEGV while executing blocks passed to Dispatch::Job#add.

backtrace of trunk (revision 4089) with gcc is as follows.

(gdb) run
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
[Switching to process 11054]
0x0000000000000000 in ?? ()
(gdb) where
#0  0x0000000000000000 in ?? ()
#1  0x000000010013b8ad in __rb_vm_objc_dispatch [inlined] () at /Users/nagachika/opt/src/MacRuby-trunk/MacRuby/dispatcher.cpp:450
#2  0x000000010013b8ad in rb_vm_call_with_cache2 (cache=0x100e31450, block=0x0, self=8592087456, klass=<value temporarily unavailable, due to optimizations>, sel=0x7fff886e8b1e, argc=3, argv=0x104a84900) at dispatcher.cpp:904
#3  0x000000010006b3a2 in rb_class_new_instance_imp (klass=8592147264, sel=<value temporarily unavailable, due to optimizations>, argc=3, argv=0x104a84900) at object.c:1962
#4  0x00000001001481dc in rb_vm_dispatch (cache=0x100e5e870, top=8590786400, self=8592147264, sel=0x100e2ffa0, block=0x0, opt=0 '\000', argc=3) at dispatcher.cpp:418
#5  0x0000000102007d25 in ?? ()
#6  0x000000010013c68a in rb_vm_call_with_cache2 (cache=0x100e312c0, block=0x0, self=8590786400, klass=<value temporarily unavailable, due to optimizations>, sel=0x7fff8211c810, argc=<value temporarily unavailable, due to optimizations>, argv=0x104a85950) at dispatcher.cpp:144
#7  0x000000010006b233 in rb_class_new_instance0 [inlined] () at /Users/nagachika/opt/src/MacRuby-trunk/MacRuby/object.c:1958
#8  0x000000010006b233 in rb_class_new_instance_imp (klass=8592105184, sel=<value temporarily unavailable, due to optimizations>, argc=0, argv=0x104a85950) at object.c:1972
#9  0x00000001001481dc in rb_vm_dispatch (cache=0x1038ee910, top=8590064448, self=8592105184, sel=0x7fff8211c858, block=0x0, opt=0 '\000', argc=0) at dispatcher.cpp:418
#10 0x00000001020099b2 in ?? ()
#11 0x000000010013f3e3 in rb_vm_block_eval (b=0x2000e7e20, argc=<value temporarily unavailable, due to optimizations>, argv=0x2000e7e78) at dispatcher.cpp:95
#12 0x00000001001481dc in rb_vm_dispatch (cache=0x104839970, top=8592071616, self=8590902944, sel=0x7fff85bb1100, block=0x0, opt=0 '\000', argc=0) at dispatcher.cpp:418
#13 0x0000000102009f25 in ?? ()
#14 0x000000010013f3e3 in rb_vm_block_eval (b=0x2000e6e60, argc=<value temporarily unavailable, due to optimizations>, argv=0x2000e6eb8) at dispatcher.cpp:95
#15 0x000000010015bd4a in rb_rescue2 (b_proc=<value temporarily unavailable, due to optimizations>, data1=<value temporarily unavailable, due to optimizations>, r_proc=0x1000f2240 <rb_block_rescue>, data2=4304291472) at vm.cpp:3596
#16 0x00007fff84ef9b90 in _dispatch_worker_thread2 ()
#17 0x00007fff84ef94e8 in _pthread_wqthread ()
#18 0x00007fff84ef9385 in start_wqthread ()

Attachments

ao-render-gcd.rb Download (6.2 KB) - added by nagachika00@… 21 months ago.
AO Bench GCD version with Dispatch::Job
test_gcd.rb Download (176 bytes) - added by nagachika00@… 21 months ago.
sample script reproduce SEGV

Change History

Changed 21 months ago by nagachika00@…

AO Bench GCD version with Dispatch::Job

follow-up: ↓ 3   Changed 21 months ago by martinlagardette@…

Hi!

Thanks for the report, but would you have a smaller reduction? We do not have any input file either btw :-)

Thanks again!

  Changed 21 months ago by lsansonetti@…

There is no input file, the script creates a new file.

in reply to: ↑ 1   Changed 21 months ago by nagachika00@…

I will try to make smaller example reproduce the SEGV. Thank you for your kindness.

Changed 21 months ago by nagachika00@…

sample script reproduce SEGV

  Changed 21 months ago by nagachika00@…

Hi.

The attached script (test_gcd.rb) can reproduce SEGV almost everytime on my environment, but rarely end normally (once over 10-20 times). It maybe depend on environment.

Best regards.

  Changed 21 months ago by nagachika00@…

I found out that this problem is fixed with r4181. Many thanks! Please close this ticket.

  Changed 21 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to MacRuby 0.7

Thanks for the check :) Indeed since r4181 the dispatch cache is thread-safe, which could explain why this problem is now fixed.

Note: See TracTickets for help on using tickets.