1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix a use-after-free bug reported by ASAN

If a fiber and thread are collected at the same time, the thread might
get collected first and the pointer on the fiber will go bad.  I don't
think we need to check whether or not this is the main fiber in order to
release its stack
This commit is contained in:
Aaron Patterson 2020-09-23 20:06:38 -07:00 committed by Aaron Patterson
parent 2db081b5ff
commit 9fb60672d5
Notes: git 2020-10-02 00:43:27 +09:00

4
cont.c
View file

@ -940,9 +940,7 @@ cont_free(void *ptr)
else {
rb_fiber_t *fiber = (rb_fiber_t*)cont;
coroutine_destroy(&fiber->context);
if (!fiber_is_root_p(fiber)) {
fiber_stack_release(fiber);
}
fiber_stack_release(fiber);
}
RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr);