summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2019-10-13 14:11:02 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2019-10-13 14:15:14 -0700
commit183b42150962e507cd69ceddb64ad2a10f02fdfa (patch)
tree1c0cb57e743b59e97b15a1a93507ee8b454e288d
parent673f3842dd520ac872bb003de393ba7ae558840a (diff)
downloadruby-183b42150962e507cd69ceddb64ad2a10f02fdfa.tar.gz
Delay the free until we stop referring to a unit
`if (unit->iseq)` might have referred to a freed unit. Therefore this commit delays its free.
-rw-r--r--mjit_worker.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mjit_worker.c b/mjit_worker.c
index c3b8d57821..2650b1d51c 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -1038,7 +1038,6 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
fclose(f);
if (!mjit_opts.save_temps)
remove_file(c_file);
- free_unit(unit);
in_jit = false; // just being explicit for return
}
else {
@@ -1237,6 +1236,9 @@ mjit_worker(void)
// Usage of jit_code might be not in a critical section.
MJIT_ATOMIC_SET(unit->iseq->body->jit_func, func);
}
+ else {
+ free_unit(unit);
+ }
CRITICAL_SECTION_FINISH(3, "in jit func replace");
#ifndef _MSC_VER