From 98a2b053f8a0c247341949a5f1c7f9307aab14bd Mon Sep 17 00:00:00 2001 From: k0kubun Date: Mon, 26 Nov 2018 15:12:31 +0000 Subject: process.c: avoid dlclose before exec because JIT-ed code may still be on stack at this time, unlike in ruby_cleanup(). This hopes to fix: (take 2) http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480207 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- mjit.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'mjit.c') diff --git a/mjit.c b/mjit.c index 5fa93a3cfa..7c8eb28481 100644 --- a/mjit.c +++ b/mjit.c @@ -134,12 +134,13 @@ init_list(struct rb_mjit_unit_list *list) because node of unit_queue and one of active_units may have the same unit during proceeding unit. */ static void -free_list(struct rb_mjit_unit_list *list) +free_list(struct rb_mjit_unit_list *list, int close_handle_p) { struct rb_mjit_unit *unit = 0, *next; list_for_each_safe(&list->head, unit, next, unode) { list_del(&unit->unode); + if (!close_handle_p) unit->handle = NULL; /* Skip dlclose in free_unit() */ free_unit(unit); } list->length = 0; @@ -787,9 +788,12 @@ mjit_child_after_fork(void) /* Finish the threads processing units and creating PCH, finalize and free MJIT data. It should be called last during MJIT - life. */ + life. + + If close_handle_p is TRUE, it calls dlclose() for JIT-ed code. So it should be FALSE + if the code can still be on stack. ...But it means to leak JIT-ed handle forever (FIXME). */ void -mjit_finish(void) +mjit_finish(int close_handle_p) { if (!mjit_enabled) return; @@ -827,9 +831,9 @@ mjit_finish(void) xfree(pch_file); pch_file = NULL; mjit_call_p = FALSE; - free_list(&unit_queue); - free_list(&active_units); - free_list(&compact_units); + free_list(&unit_queue, close_handle_p); + free_list(&active_units, close_handle_p); + free_list(&compact_units, close_handle_p); finish_conts(); mjit_enabled = FALSE; -- cgit v1.2.3