-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when matching regex in multiple threads #3670
Comments
We are experiencing this issue as well and it resulted in a large number of corrupted data in YAML serialized ActiveRecord columns. |
Based on the original example, I created a simple test case which always fails with 10.times.map{Thread.new{100000.times{"foobar".force_encoding("UTF-8") =~ /foo/i}}}.map(&:value) I would recommend that http://jruby.org/2016/01/20/jruby-1-7-24 is updated with this critical bug information and with recommendation not to use this version in multi-threaded production applications. This bug most probably will not be caught by application test suites and might cause critical problems in production. |
Temporary fix is in jruby/joni@f23bffa by making SLOW_IC stateless and moving the cached buffer into matcher instance. In the future we need to get rid of those stateful caches and IntHolder by making them local. |
Commit that revealed that bug in EXACT_IC: jruby/joni@eda1681 |
@lopex Perhaps the caching of Regex was not as good and something got fixed around these releases? That would trigger more sharing of this field, wouldn't it? |
@headius jruby/joni@eda1681 changed the way heuristics applied fast skipping / fast failing by favouring EXACT_IC for this very case. EXACT_IC had a buffer as an instance field and since it itself is scoped by Regexp instance, the buffer essentially turned out to be Regexp global (in case of a literal regexp). The fix just moved that buffer into Matcher instance for potential reuse when jumping in/out of bytecode interpreter. So caching of regexps never had any effect on this. |
I updated ruby-2.3 to use new joni, but we'll need a release for 9.1. |
Oh, and we'll need to apply it to 1.7 of course. |
Hi all, we are experiencing this same issue. Which is the recommended workaround until new versions including a fix for this are released? Should we downgrade to Thanks |
@ncuesta downgrading I think is the safest bet until we put out new releases. We will hopefully have a new release out in the next week to 2 weeks at most. At this point we are tidying up after the last dev cycle... |
Thanks @enebo! |
we also started to notice this in the new logstash 2.3 release which includes 1.7.24, in useragent filter logstash-plugins/logstash-filter-useragent#25 and we are tracking this regex issue in elastic/logstash#4977 |
joni has been updated and released for a few weeks with this addressed. Closing. |
Will there be a new 9.0.x release for this fix or do we have to wait until 9.1? The JDBC MSSQL adapter code is full of //i Regex expressions, which produce 'nice' exceptions like 'no columns for table: ' or 'undefined method `[]' for nil:NilClass' |
@MartinKoerner There will only be a 9.1 release which should be this week... |
@DzmitryNikitsin I see this comment sent to me as email but not in github issues. Was this On Fri, May 6, 2016 at 9:15 PM, DzmitryNikitsin notifications@github.com
blog: http://blog.enebo.com twitter: tom_enebo |
Yes, issue was fixed on 9.1.0.0. Thanks, From: Thomas E Enebo notifications@github.com I see this comment sent to me as email but not in github issues. Was this On Fri, May 6, 2016 at 9:15 PM, DzmitryNikitsin notifications@github.com
blog: http://blog.enebo.com twitter: tom_enebo — |
1.7.24 and 9.0.5.0 both have a pretty serious regression when matching against utf8 strings in multiple threads at the same time. This bug does not appear to be present in 1.7.23 or 9.0.4.0.
If multiple threads are running code like this, with completely unshared string and regex objects:
eventually one of the threads will throw an error like this:
The error doesn't occur if I remove the call to #force_encoding or if I remove the "i" flag from the regex.
See this gist for a full reproducible test case and examples of running it on different JRuby versions:
https://gist.github.com/marshalium/3e62c2affbd2ce95757f
The text was updated successfully, but these errors were encountered: