Issue #4992 has been updated by Motohiro KOSAKI.

Assignee changed from Motohiro KOSAKI to Koichi Sasada

How's this?


Index: vm_core.h
===================================================================
--- vm_core.h	(revision 32446)
+++ vm_core.h	(working copy)
@@ -285,6 +285,7 @@
     VALUE thgroup_default;
 
     int running;
+    int inhibit_thread_creation;
     int thread_abort_on_exception;
     unsigned long trace_flag;
     volatile int sleeper;
Index: thread.c
===================================================================
--- thread.c	(revision 32447)
+++ thread.c	(working copy)
@@ -367,6 +367,7 @@
 
     thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th);
     st_foreach(vm->living_threads, terminate_i, (st_data_t)th);
+    vm->inhibit_thread_creation = 1;
 
     while (!rb_thread_alone()) {
 	PUSH_TAG();
@@ -583,6 +584,10 @@
 {
     rb_thread_t *th;
     VALUE thread = rb_thread_alloc(klass);
+
+    if (GET_VM()->inhibit_thread_creation)
+	rb_raise(rb_eThreadError, "can't alloc thread");
+
     rb_obj_call_init(thread, argc, argv);
     GetThreadPtr(thread, th);
     if (!th->first_args) {

----------------------------------------
Bug #4992: finalizer中??Thread.new???SEGV
http://redmine.ruby-lang.org/issues/4992

Author: Shota Fukumori
Status: Assigned
Priority: Normal
Assignee: Koichi Sasada
Category: core
Target version: 1.9.3
ruby -v: -


以?????????????????????????????SEGV????????

$ ruby -e'ObjectSpace.define_finalizer(""){Thread.new{}}'  
$ ruby -e'ObjectSpace.define_finalizer(""){Thread.new{}}'
SEGV received in SEGV handler
$ ruby -e'ObjectSpace.define_finalizer(""){2.times{Thread.new{}}}'
SEGV received in SEGV handler
$ ruby -e'ObjectSpace.define_finalizer(""){2.times{Thread.new{}}}'
SEGV received in SEGV handler


2.times??????????????確?????????????2??????1????????????????????????????


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