aboutsummaryrefslogtreecommitdiffstats
path: root/cont.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2020-09-23 20:06:38 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2020-10-01 08:42:52 -0700
commit9fb60672d55162a92ab7e97b000a7e277458aab1 (patch)
tree4b6be6987a600aeaa6bde3ee1c675e5be8022c9e /cont.c
parent2db081b5ffb07a2e6bdac58122fa3466830b12a9 (diff)
downloadruby-9fb60672d55162a92ab7e97b000a7e277458aab1.tar.gz
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
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/cont.c b/cont.c
index 0304f4c60e..561398d618 100644
--- a/cont.c
+++ b/cont.c
@@ -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);