ruby-changes:55905
From: Takashi <ko1@a...>
Date: Wed, 29 May 2019 16:23:27 +0900 (JST)
Subject: [ruby-changes:55905] Takashi Kokubun: ce7b1132c5 (trunk): Do not call FIX2INT while GC.compact may be running
https://git.ruby-lang.org/ruby.git/commit/?id=ce7b1132c5 From ce7b1132c581375dafa6a5b5071e66eaa362b429 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Wed, 29 May 2019 16:22:26 +0900 Subject: Do not call FIX2INT while GC.compact may be running because FIX2INT might crash by moving method entry pointer: http://ci.rvm.jp/results/trunk-mjit@silicon-docker/2063412 diff --git a/mjit_worker.c b/mjit_worker.c index 4a7d47c..0deee99 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -944,7 +944,7 @@ load_func_from_so(const char *so_file, const char *funcname, struct rb_mjit_unit https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L944 } static void -print_jit_result(const char *result, const struct rb_mjit_unit *unit, const double duration, const char *c_file) +print_jit_result(const char *result, const struct rb_mjit_unit *unit, const double duration, int lineno, const char *c_file) { if (unit->iseq == NULL) { verbose(1, "JIT %s (%.1fms): (GCed) -> %s", result, duration, c_file); @@ -952,7 +952,7 @@ print_jit_result(const char *result, const struct rb_mjit_unit *unit, const doub https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L952 else { verbose(1, "JIT %s (%.1fms): %s@%s:%d -> %s", result, duration, RSTRING_PTR(unit->iseq->body->location.label), - RSTRING_PTR(rb_iseq_path(unit->iseq)), FIX2INT(unit->iseq->body->location.first_lineno), c_file); + RSTRING_PTR(rb_iseq_path(unit->iseq)), lineno, c_file); } } @@ -1075,11 +1075,12 @@ convert_unit_to_func(struct rb_mjit_unit *unit) https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L1075 return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC; } + // FIX2INT calls method_entry_get(). Thus we should not call it while GC or GC.compact may happen. + int lineno = FIX2INT(unit->iseq->body->location.first_lineno); { VALUE s = rb_iseq_path(unit->iseq); const char *label = RSTRING_PTR(unit->iseq->body->location.label); const char *path = RSTRING_PTR(s); - int lineno = FIX2INT(unit->iseq->body->location.first_lineno); verbose(2, "start compilation: %s@%s:%d -> %s", label, path, lineno, c_file); fprintf(f, "/* %s@%s:%d */\n\n", label, path, lineno); } @@ -1096,7 +1097,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit) https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L1097 if (!success) { if (!mjit_opts.save_temps) remove_file(c_file); - print_jit_result("failure", unit, 0, c_file); + print_jit_result("failure", unit, 0, lineno, c_file); return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC; } @@ -1134,8 +1135,7 @@ convert_unit_to_func(struct rb_mjit_unit *unit) https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L1135 if ((uintptr_t)func > (uintptr_t)LAST_JIT_ISEQ_FUNC) { CRITICAL_SECTION_START(3, "end of jit"); add_to_list(unit, &active_units); - if (unit->iseq) - print_jit_result("success", unit, end_time - start_time, c_file); + print_jit_result("success", unit, end_time - start_time, lineno, c_file); CRITICAL_SECTION_FINISH(3, "end of jit"); } return (mjit_func_t)func; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/