Project

General

Profile

Bug #15013

thread_pthread.c: reinitialize ubf_list at fork

Added by normalperson (Eric Wong) 11 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:88578]

Description

thread_pthread.c: reinitialize ubf_list at fork

It's possible for the ubf_list_head to be populated with dead
threads at fork or the ubf_list_lock to be held, so reinitialize
both at startup.

And while we're at it, use a static initializer at startup
to save a library call and kill some ifdef.


Files

Associated revisions

Revision 17e4aff2
Added by normal 11 months ago

thread_pthread.c: reinitialize ubf_list at fork

It's possible for the ubf_list_head to be populated with dead
threads at fork or the ubf_list_lock to be held, so reinitialize
both at startup.

And while we're at it, use a static initializer at startup
to save a library call and kill some ifdef.

[ruby-core:88578] [Bug #15013]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 64485
Added by normalperson (Eric Wong) 11 months ago

thread_pthread.c: reinitialize ubf_list at fork

It's possible for the ubf_list_head to be populated with dead
threads at fork or the ubf_list_lock to be held, so reinitialize
both at startup.

And while we're at it, use a static initializer at startup
to save a library call and kill some ifdef.

[ruby-core:88578] [Bug #15013]

Revision 64485
Added by normal 11 months ago

thread_pthread.c: reinitialize ubf_list at fork

It's possible for the ubf_list_head to be populated with dead
threads at fork or the ubf_list_lock to be held, so reinitialize
both at startup.

And while we're at it, use a static initializer at startup
to save a library call and kill some ifdef.

[ruby-core:88578] [Bug #15013]

Revision 64635
Added by duerst (Martin Dürst) 10 months ago

define ubf_list_atfork() as empty on cygwin

History

#1

Updated by normalperson (Eric Wong) 11 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r64485.


thread_pthread.c: reinitialize ubf_list at fork

It's possible for the ubf_list_head to be populated with dead
threads at fork or the ubf_list_lock to be held, so reinitialize
both at startup.

And while we're at it, use a static initializer at startup
to save a library call and kill some ifdef.

[ruby-core:88578] [Bug #15013]

Updated by nagachika (Tomoyuki Chikanaga) 4 months ago

MEMO: backporting r64485 and r64635 cause some make test failures on my environment.
I give up to fix these for just now.

#257 test_fork.rb:31:in `<top (required)>':
     begin
       r, w = IO.pipe
       if pid1 = fork
         w.close
         r.read(1)
         Process.kill("USR1", pid1)
         _, s = Process.wait2(pid1)
         s.success? ? :ok : :ng
       else
         r.close
         if pid2 = fork
           trap("USR1") { Time.now.to_s; Process.kill("USR2", pid2) }
           w.close
           Process.wait2(pid2)
         else
           w.close
           sleep 0.2
         end
         exit true
       end
     rescue NotImplementedError
       :ok
     end
  #=> "ng" (expected "ok")  [ruby-core:28924]
stderr output is not empty
   bootstraptest.tmp.rb:13:in `kill': No such process (Errno::ESRCH)
           from bootstraptest.tmp.rb:13:in `block in <main>'
           from bootstraptest.tmp.rb:15:in `wait2'
           from bootstraptest.tmp.rb:15:in `<main>'
test_fork.rb            FAIL 1/5
#455 test_io.rb:87:in `block in <top (required)>':
       at_exit { p :foo }

       megacontent = "abc" * 12345678
       #File.open("megasrc", "w") {|f| f << megacontent }

       t0 = Thread.main
       Thread.new { sleep 0.001 until t0.stop?; Process.kill(:INT, $$) }

       r1, w1 = IO.pipe
       r2, w2 = IO.pipe
       t1 = Thread.new { w1 << megacontent; w1.close }
       t2 = Thread.new { r2.read; r2.close }
       IO.copy_stream(r1, w2) rescue nil
       w2.close
       r1.close
       t1.join
       t2.join
  #=> killed by SIGKILL (signal 9) (timeout)  megacontent-copy_stream
test_io.rb              FAIL 1/9
FAIL 2/1201 tests failed

Also available in: Atom PDF