Feature #2012: Set event_flags on thread creation if hook exists
http://redmine.ruby-lang.org/issues/show/2012

Author: Mark Moseley
Status: Open, Priority: Normal
Target version: 1.9.x

In ruby-debug, when a user sets a breakpoint that ends up executed by a later-created thread, then nothing will happen.

The only solution that I have at this point is to always set RUBY_EVENT_VM for all living threads every time the hook proc is called. I've tried to optimize this and failed; the cost of figuring out accurately if there's a new thread is always greater than the brute-force method of just always forcing the flags to be updated.

I propose adding the following patch to the core:

Index: thread.c
===================================================================
--- thread.c    (revision 24710)
+++ thread.c    (working copy)
@@ -497,6 +497,9 @@
     th->thgroup = GET_THREAD()->thgroup;

     native_mutex_initialize(&th->interrupt_lock);
+    if (GET_VM()->event_hooks != NULL)
+        th->event_flags |= RUBY_EVENT_VM;
+
     /* kick thread */
     st_insert(th->vm->living_threads, thval, (st_data_t) th->thread_id);
     native_thread_create(th);

This passes all Ruby tests, and fixes the problem that I've outlined.


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