From 704dd25812f34228a28f37c37757a675ad078a2b Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 6 Feb 2023 09:29:39 +0100 Subject: TestThreadInstrumentation: emit the EXIT event sooner ``` 1) Failure: TestThreadInstrumentation#test_thread_instrumentation [/tmp/ruby/src/trunk-repeat20-asserts/test/-ext-/thread/test_instrumentation_api.rb:33]: Call counters[4]: [3, 4, 4, 4, 0]. Expected 0 to be > 0. ``` We fire the EXIT hook after the call to `thread_sched_to_dead` which mean another thread might be running before the `EXIT` hook have been executed. --- thread_pthread.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index 944570767e..693d8f10e8 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -449,6 +449,13 @@ thread_sched_to_waiting(struct rb_thread_sched *sched) rb_native_mutex_unlock(&sched->lock); } +static void +thread_sched_to_dead(struct rb_thread_sched *sched) +{ + RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_EXITED); + thread_sched_to_waiting(sched); +} + static void thread_sched_yield(struct rb_thread_sched *sched, rb_thread_t *th) { @@ -1171,8 +1178,6 @@ thread_start_func_1(void *th_ptr) #else thread_start_func_2(th, &stack_start); #endif - - RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_EXITED); } #if USE_THREAD_CACHE /* cache thread */ -- cgit v1.2.1