From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B8BE21F453 for ; Wed, 31 Oct 2018 19:19:19 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] mjit: recheck unit->iseq after GC wakeup Date: Wed, 31 Oct 2018 19:19:19 +0000 Message-Id: <20181031191919.26547-1-e@80x24.org> List-Id: The iseq may be GC-ed while we were waiting for it. --- mjit_worker.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mjit_worker.c b/mjit_worker.c index 18ac81d6fcb..2eca3d1559e 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -1086,8 +1086,21 @@ convert_unit_to_func(struct rb_mjit_unit *unit, struct rb_call_cache *cc_entries verbose(3, "Waiting wakeup from GC"); rb_native_cond_wait(&mjit_gc_wakeup, &mjit_engine_mutex); } - in_jit = TRUE; + + /* We need to check again here because we could've waited on GC above */ + if (unit->iseq == NULL) { + fclose(f); + if (!mjit_opts.save_temps) + remove_file(c_file); + free_unit(unit); + } + else { + in_jit = TRUE; + } CRITICAL_SECTION_FINISH(3, "before mjit_compile to wait GC finish"); + if (unit->iseq == NULL) { + return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC; + } { VALUE s = rb_iseq_path(unit->iseq); -- EW