[#89806] [Ruby trunk Bug#15306] Generate prelude.c using miniruby — v.ondruch@...
Issue #15306 has been reported by vo.x (Vit Ondruch).
3 messages
2018/11/15
[ruby-core:89854] [Ruby trunk Bug#15316] rb_postponed_job_register not thread-safe
From:
takashikkbn@...
Date:
2018-11-18 08:40:11 UTC
List:
ruby-core #89854
Issue #15316 has been updated by k0kubun (Takashi Kokubun).
> OK, please do.
Done, in r65785. Comments from your point of view would be much appreciated.
> I am also testing a minor cleanup
looks fine.
> Somewhat related. We need to ensure a consistent state of the queue (either postponed_job or workqueue).
In a sense that postponed_job could be in an unexpected state by creating a child Ruby process which suddenly lost MJIT worker thread modifying postponed_job queue, agreed.
> Right now, we cannot guarantee a consistent state after forking; either.
Yeah, I found that issue when I was creating r65785. In r65785, I added `mjit_pause` before fork and `mjit_resume`s after fork (in different places depending on whether it's child or parent). As long as MJIT worker thread is absent when Ruby is forked, I think the situation became a little better.
----------------------------------------
Bug #15316: rb_postponed_job_register not thread-safe
https://bugs.ruby-lang.org/issues/15316#change-74912
* Author: normalperson (Eric Wong)
* Status: Open
* Priority: Normal
* Assignee: k0kubun (Takashi Kokubun)
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Consider following execution timeline for two threads, t1 and t2.
(should be 2 columns, I only have fixed-width fonts for display)
```
t1 t2 (mjit-worker)
-----------------------------------------------------------------------------
vm->postponed_job_index increment #1
pjob[0]->func = ...
pjob[0]->data = ...
vm->postponed_job_index increment #2
RUBY_VM_SET_POSTPONED_JOB_INTERRUPT
rb_postponed_job_flush
sees result of increment #2 from t2
tries to access pjob[1] => CRASH
pjob[1]->func = ...
pjob[1]->data = ...
RUBY_VM_SET_POSTPONED_JOB_INTERRUPT
```
So it looks like we need a THREAD-SAFE (not necessarily async-safe)
version of rb_postponed_job_register. Or a one-off API for MJIT...
job registration for MJIT.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>