From 16c765990ceaf5fb1efaeba2850083cfec7c137e Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 10 Dec 2020 00:17:59 -0800 Subject: Use list_for_each_safe when list_del is used inside list_for_each seems to cause all the SEGVs we've seen. --- mjit_worker.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mjit_worker.c') diff --git a/mjit_worker.c b/mjit_worker.c index 725a922e47..377fd411e5 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; -- cgit v1.2.3