mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
fix native_thread_destroy()
timing
With M:N thread scheduler, the native thread (NT) related resources should be freed when the NT is no longer needed. So the calling `native_thread_destroy()` at the end of `is will be freed when `thread_cleanup_func()` (at the end of Ruby thread) is not correct timing. Call it when the corresponding Ruby thread is collected.
This commit is contained in:
parent
2794a8fef6
commit
cdb36dfe7d
4 changed files with 26 additions and 32 deletions
9
thread.c
9
thread.c
|
@ -508,16 +508,13 @@ thread_cleanup_func(void *th_ptr, int atfork)
|
|||
* Unfortunately, we can't release native threading resource at fork
|
||||
* because libc may have unstable locking state therefore touching
|
||||
* a threading resource may cause a deadlock.
|
||||
*
|
||||
* FIXME: Skipping native_mutex_destroy(pthread_mutex_destroy) is safe
|
||||
* with NPTL, but native_thread_destroy calls pthread_cond_destroy
|
||||
* which calls free(3), so there is a small memory leak atfork, here.
|
||||
*/
|
||||
if (atfork)
|
||||
if (atfork) {
|
||||
th->nt = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
rb_native_mutex_destroy(&th->interrupt_lock);
|
||||
native_thread_destroy(th);
|
||||
}
|
||||
|
||||
static VALUE rb_threadptr_raise(rb_thread_t *, int, VALUE *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue