ruby-changes:53356
From: k0kubun <ko1@a...>
Date: Tue, 6 Nov 2018 17:01:34 +0900 (JST)
Subject: [ruby-changes:53356] k0kubun:r65572 (trunk): mjit.c: don't use mutex before checking availability
k0kubun 2018-11-06 17:01:28 +0900 (Tue, 06 Nov 2018) New Revision: 65572 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65572 Log: mjit.c: don't use mutex before checking availability Modified files: trunk/mjit.c Index: mjit.c =================================================================== --- mjit.c (revision 65571) +++ mjit.c (revision 65572) @@ -26,16 +26,18 @@ mjit_copy_job_handler(void *data) https://github.com/ruby/ruby/blob/trunk/mjit.c#L26 { struct mjit_copy_job *job = data; int finish_p; + if (stop_worker_p) { + /* `copy_cache_from_main_thread()` stops to wait for this job. Then job data which is + allocated by `alloca()` could be expired and we might not be able to access that. + Also this should be checked before CRITICAL_SECTION_START to ensure that mutex is alive. */ + return; + } + CRITICAL_SECTION_START(3, "in mjit_copy_job_handler"); finish_p = job->finish_p; CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler"); - - if (stop_worker_p || finish_p) { - /* `stop_worker_p`: `copy_cache_from_main_thread()` stops to wait for this job. - Then job data which is allocated by `alloca()` could be expired and we might - not be able to access that. - `finish_p`: make sure that this job is never executed while job is being modified. */ - return; + if (finish_p) { + return; /* make sure that this job is never executed while job is being modified. */ } if (job->cc_entries) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/