Bug #657: Thread.new { fork }
http://redmine.ruby-lang.org/issues/show/657

Author: James M. Lawrence
Status: Open, Priority: Normal
Category: core

% uname -a
Darwin tiamat.local 9.5.0 Darwin Kernel Version 9.5.0: Wed Sep  3 11:29:43 PDT 2008; root:xnu-1228.7.58~1/RELEASE_I386 i386
% ./ruby --version
ruby 1.9.0 (2008-10-19 revision 19843) [i386-darwin9.5.0]

% ./ruby -e 'Thread.new { fork }'
% killall ruby
[BUG] pthread_mutex_lock: 22
ruby 1.9.0 (2008-10-19 revision 19843) [i386-darwin9.5.0]

-- control frame ----------
---------------------------
-- backtrace of native function call (Use addr2line) --
0x12c1e9
0x29ac6
0x29b05
0x12c352
0x12cf8c
0x12fc0c
0x12cddd
0x96bf16f5
0x96bf15b2
-------------------------------------------------------
% atos -o ./ruby -f hex
rb_vm_bugreport (in ruby)
report_bug (in ruby)
rb_bug (in ruby)
native_mutex_lock (in ruby)
rb_thread_interrupt (in ruby)
timer_thread_function (in ruby)
thread_timer (in ruby)
0x96bf16f5
0x96bf15b2

% ./ruby -e 'Thread.new { fork { Thread.new { } } }'
-e:1: Fixnum

% ./ruby -e 'Thread.new { fork { Thread.new { } } }'
-e:1: Fixnum

% ./ruby -e 'Thread.new { fork { Thread.new { } } }'
[BUG] rb_thread_terminate_all: called by child thread (0x249fb0, 0x24a290)
ruby 1.9.0 (2008-10-19 revision 19843) [i386-darwin9.5.0]

-- control frame ----------
---------------------------
-- backtrace of native function call (Use addr2line) --
0x12c1e9
0x29ac6
0x29b05
0x12d078
0x2de7e
0x2e080
0x8e327
0x120c43
0x120a3f
0x1203f9
0x11cd91
0x12927b
0x127f24
0x1280b3
0x12d306
0x12c721
0x96bf16f5
0x96bf15b2
-------------------------------------------------------
% atos -o ./ruby -f hex2
rb_vm_bugreport (in ruby)
report_bug (in ruby)
rb_bug (in ruby)
rb_thread_terminate_all (in ruby)
ruby_cleanup (in ruby)
ruby_stop (in ruby)
rb_f_fork (in ruby)
call_cfunc (in ruby)
vm_call_cfunc (in ruby)
vm_call_method (in ruby)
vm_exec_core (in ruby)
vm_exec (in ruby)
invoke_block_from_c (in ruby)
vm_invoke_proc (in ruby)
thread_start_func_2 (in ruby)
thread_start_func_1 (in ruby)
0x96bf16f5
0x96bf15b2

% ./ruby -e 'Thread.new { fork { Thread.new { } } }'
-e:1: [BUG] Segmentation fault
ruby 1.9.0 (2008-10-19 revision 19843) [i386-darwin9.5.0]

-- control frame ----------
c:0004 p:---- s:0007 b:0007 l:000006 d:000006 CFUNC  :fork
c:0003 p:0009 s:0004 b:0004 l:000294 d:000574 BLOCK  -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH 
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP    
---------------------------
DBG> : "-e:1:in `fork'"
DBG> : "-e:1:in `block in <main>'"
-- backtrace of native function call (Use addr2line) --
0x12c1e9
0x29ac6
0x29b05
0xc689f
0x96c2d09b
0xffffffff
-------------------------------------------------------
% atos -o ./ruby -f hex3
rb_vm_bugreport (in ruby)
report_bug (in ruby)
rb_bug (in ruby)
sigpipe (in ruby)
0x96c2d09b
0xffffffff

=======================================================
Linux
=======================================================
$ uname -a
Linux tiamat-linux 2.6.24-19-generic #1 SMP Wed Aug 20 22:56:21 UTC 2008 i686 GNU/Linux
$ ./ruby --version
ruby 1.9.0 (2008-10-19 revision 19843) [i686-linux]
$ ./ruby -e 'Thread.new { fork }'
$ killall ruby
[BUG] $
$ ./ruby -e 'Thread.new { fork { Thread.new { } } }'
-e:1: Fixnum

=======================================================
I deleted a related bug on rubyforge (#22209) which unnecessarily involved DRb.


----------------------------------------
http://redmine.ruby-lang.org