mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
thread_cleanup: set CFP to NULL before clearing ec's stack
We clear the CFP first so that if a sampling profiler interrupts the current thread during `rb_ec_set_vm_stack`,
`thread_profile_frames` returns early instead of trying to walk the stack that's no longer set on the ec.
The early return in `thread_profile_frames` was introduced at eab7f4623f
.
Fixes [Bug #21441]
This commit is contained in:
parent
1fb5ab411f
commit
a52a2e852a
1 changed files with 3 additions and 3 deletions
6
vm.c
6
vm.c
|
@ -3528,10 +3528,10 @@ rb_ec_initialize_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size)
|
|||
void
|
||||
rb_ec_clear_vm_stack(rb_execution_context_t *ec)
|
||||
{
|
||||
rb_ec_set_vm_stack(ec, NULL, 0);
|
||||
|
||||
// Avoid dangling pointers:
|
||||
// set cfp to NULL before clearing the stack in case `thread_profile_frames`
|
||||
// gets called in this middle of `rb_ec_set_vm_stack` via signal handler.
|
||||
ec->cfp = NULL;
|
||||
rb_ec_set_vm_stack(ec, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue