summaryrefslogtreecommitdiff
path: root/mjit_worker.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-12-10 00:17:59 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2020-12-10 00:18:35 -0800
commit16c765990ceaf5fb1efaeba2850083cfec7c137e (patch)
tree6d2c62510bfc5196fe3b2536007d6098035a9d94 /mjit_worker.c
parentda3bca513f437b05b3953c3712ff48621fc5e008 (diff)
Use list_for_each_safe when list_del is used inside
list_for_each seems to cause all the SEGVs we've seen.
Diffstat (limited to 'mjit_worker.c')
-rw-r--r--mjit_worker.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mjit_worker.c b/mjit_worker.c
index 725a922..377fd41 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -910,8 +910,8 @@ compile_compact_jit_code(char* c_file)
}
// We need to check again here because we could've waited on GC above
bool iseq_gced = false;
- struct rb_mjit_unit *child_unit = 0;
- list_for_each(&active_units.head, child_unit, unode) {
+ struct rb_mjit_unit *child_unit = 0, *next;
+ list_for_each_safe(&active_units.head, child_unit, next, unode) {
if (child_unit->iseq == NULL) { // ISeq is GC-ed
iseq_gced = true;
verbose(1, "JIT compaction: A method for JIT code u%d is obsoleted. Compaction will be skipped.", child_unit->id);
@@ -1303,7 +1303,7 @@ unload_units(void)
prev_queue_calls = max_queue_calls;
bool unloaded_p = false;
- list_for_each(&active_units.head, unit, unode) {
+ list_for_each_safe(&active_units.head, unit, next, unode) {
if (unit->used_code_p) // We can't unload code on stack.
continue;