Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Dynamic "once" regexps are not as atomic as in MRI #2798
The test_once_multithread test in MRI's ruby/test_regexp.rb tries to guarantee that the contents of a dynamic "once" regexp (e.g.
My fix just puts atomic guarantees around the update of the cache.
I have filed https://bugs.ruby-lang.org/issues/11026 to clarify with ruby-core how atomic a dynamic "once" regexp should actually be.
added a commit
Apr 2, 2015
referenced this issue
Mar 15, 2016
After some discussion with @enebo, we figured out that
And once this has run once, MRI additionally flushes all the iseqs for the regexp and just leaves the resulting object in the iseq.
So, unless that changes in MRI, we need to make the same guarantee.
We also discovered that IR currently will evaluate all the pieces of the dregexp every time it is encountered, which is at best a performance problem and at worst a severe semantic difference with MRI. So this needs to be fixed.
Marking for 22.214.171.124. Hopefully we can get it in.
added a commit
Mar 16, 2016
I pushed 256e753, which removes the locking I had in the JVM6 jit and replaces it with an atomic reference. The evaluation of the dregexp/o operands may run in two threads at the same time, but that can't be fixed right now until IR wraps the entire dregexp/o in a locking mechanism as discussed above. So for now, we guarantee the dregexp/o will only ever return one value.
I'm actually going to call this fixed. It's a grey area, to be sure, and the hassle to guarantee once-only evaluation of the
If someone runs into this being a problem, they can file a bug and we can debate it with them and MRI.