Project

General

Profile

Actions

Feature #2012

closed

Set event_flags on thread creation if hook exists

Added by mark-moseley (Mark Moseley) about 15 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
[ruby-core:25191]

Description

=begin
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.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0