Free the native thread of the main thread on FREE_AT_EXIT

This commit is contained in:
Peter Zhu 2025-10-03 19:51:01 -04:00
parent 8eb28da3e7
commit 1858233ffa
Notes: git 2025-10-04 22:22:51 +00:00
3 changed files with 12 additions and 2 deletions

View File

@ -64,6 +64,8 @@ void rb_thread_io_close_wait(struct rb_io *);
void rb_ec_check_ints(struct rb_execution_context_struct *ec);
void rb_thread_free_native_thread(void *th_ptr);
RUBY_SYMBOL_EXPORT_BEGIN
void *rb_thread_prevent_fork(void *(*func)(void *), void *data); /* for ext/socket/raddrinfo.c */

View File

@ -529,6 +529,15 @@ thread_cleanup_func(void *th_ptr, int atfork)
rb_native_mutex_destroy(&th->interrupt_lock);
}
void
rb_thread_free_native_thread(void *th_ptr)
{
rb_thread_t *th = th_ptr;
native_thread_destroy_atfork(th->nt);
th->nt = NULL;
}
static VALUE rb_threadptr_raise(rb_thread_t *, int, VALUE *);
static VALUE rb_thread_to_s(VALUE thread);

3
vm.c
View File

@ -3306,8 +3306,7 @@ ruby_vm_destruct(rb_vm_t *vm)
rb_id_table_free(vm->constant_cache);
set_free_table(vm->unused_block_warning_table);
xfree(th->nt);
th->nt = NULL;
rb_thread_free_native_thread(th);
#ifndef HAVE_SETPROCTITLE
ruby_free_proctitle();