Skip to content

Commit 183b421

Browse files
committed
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.
1 parent 673f384 commit 183b421

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mjit_worker.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,6 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
10381038
fclose(f);
10391039
if (!mjit_opts.save_temps)
10401040
remove_file(c_file);
1041-
free_unit(unit);
10421041
in_jit = false; // just being explicit for return
10431042
}
10441043
else {
@@ -1237,6 +1236,9 @@ mjit_worker(void)
12371236
// Usage of jit_code might be not in a critical section.
12381237
MJIT_ATOMIC_SET(unit->iseq->body->jit_func, func);
12391238
}
1239+
else {
1240+
free_unit(unit);
1241+
}
12401242
CRITICAL_SECTION_FINISH(3, "in jit func replace");
12411243

12421244
#ifndef _MSC_VER

0 commit comments

Comments
 (0)