diff options
author | Aaron Patterson <[email protected]> | 2020-09-23 20:06:38 -0700 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2020-10-01 08:42:52 -0700 |
commit | 9fb60672d55162a92ab7e97b000a7e277458aab1 (patch) | |
tree | 4b6be6987a600aeaa6bde3ee1c675e5be8022c9e /cont.c | |
parent | 2db081b5ffb07a2e6bdac58122fa3466830b12a9 (diff) |
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
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3571
Diffstat (limited to 'cont.c')
-rw-r--r-- | cont.c | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -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); |