-
-
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
JRuby throws java.lang.ArrayIndexOutOfBoundsException #3781
Comments
@dennis-d Can you try running this again with JRUBY_OPTS='--1.9 -Xbacktrace.style=raw -d' and see what we can in a deeper stack trace. Although that might not figure this out. So there are two problems:
So we definitely have an issue here. I also think something is doing something in your app that you are not expecting though. Tough to know until we figure out more though. |
I tried making a simple application and put a Kernel.exit into a controller and no crash... |
$ jruby -Xbacktrace.style=raw -d -S rake cucumber:platform FEATURE=features/manage_reports.feature:129 --trace Exception @javascript Capybara::Poltergeist::TimeoutError occured. Capybara::Poltergeist::TimeoutError occured. Capybara::Poltergeist::TimeoutError occured. Failing Scenarios: 1 scenario (1 failed) |
here is the output of the command running the cucumber test. What is weird it fails with simple validation - email can't be blank, and this is the only test that is failing , but we have a ton of similar test and they all work just fine. |
I just confirmed that the same test passes on latest rails 3.2.22.2. all other gems are the same |
Command output with rails 3.2 Exception |
@dennis-d So just changing to rails 3.2.22.2 and all is well again? In original report I see 4.1.15 and you last comment shows some stacktrace with 3.2 but with no AAIOBE in it. Are these other exceptions normal for you? A few things:
This post is mostly about me not seeing any new info and hoping we can localize this issue bit. App bugs can be tough to reduce... |
OK, I found a chunk of code that cause the problem, and I change it on out side. And error goes away But here is an example: We have a mode with multiple validations
|
@dennis-d oh this is interesting. Adding to our milestone to make sure we see if we can reduce this for 9.1 quickly. |
@enebo What did you want to do with this one? |
@headius not sure but I see a closure with a return in a class body. Looks like we have some basic semantic problem here (perhaps proc and not a lambda sort of thing). I guess we fix if we can simplify this test case otherwise we probably punt one point. |
Pretty sure I know what this is. There appears to be a TracePoint or set_trace_func installed that's trying to report an exception raised when a thread bubbles out some flow control exception.
...so the frame stack is empty...
...while trying to construct a LocalJumpError...
...while finishing up a Thread. |
And a reproduction in JRuby:
|
Note my repro is for a slightly different case: tracing Thread creation blows up in the same way because there's nothing on the frame stack. The original case that re-raises a LocalJumpError appears to be gone in 9.1. |
Ok, summarizing:
Because this is not specifically a 9k bug, I'm moving it to 1.7.26, so we can get rid of that exception raise at thread root. The larger issue I'll file separately. It affects both 1.7 and 9k, but only 9k will have thread-root-level trace events after this issue gets fixed. |
When a non-local flow event bubbles out of a thread, it lazily triggers a LocalJumpError to be created, along which path a hook event for "raise" fires. Unfortunately this tries to access the current frame and stack trace information, which are already popped off the stack by the thread's proc. This change re-pushes that frame and stack trace info around the creation of the exception, so that the hook has appropriate info available. Fixes #3781
I've done a somewhat ugly fix in 9dcc41c that just re-pushes the need information into the thread context around the exception creation. It allows this to work correctly as in JRuby 9k, and since the hook has the frame's top-level it should get a usable binding too. This is about as far as I want to push it. Given that set_trace_func hooks always acquire a binding, I'm not sure we can do less than this (like my initial idea of just creating the exception in a lightweight way and manually triggering the hook, which would still produce a bad binding. The approach I used might also work for the thread begin/end hooks in 9k. |
Exception in thread "Ruby-0-Thread-38: /Users/dennis/.rvm/gems/jruby-1.7.24/gems/puma-3.2.0-java/lib/puma/thread_pool.rb:67" java.lang.ArrayIndexOutOfBoundsException: -1
at org.jruby.runtime.ThreadContext.getCurrentFrame(ThreadContext.java:479)
at org.jruby.runtime.ThreadContext.getFrameName(ThreadContext.java:606)
at org.jruby.exceptions.RaiseException.doCallEventHook(RaiseException.java:235)
at org.jruby.exceptions.RaiseException.preRaise(RaiseException.java:212)
at org.jruby.exceptions.RaiseException.preRaise(RaiseException.java:196)
at org.jruby.exceptions.RaiseException.(RaiseException.java:141)
at org.jruby.Ruby.newLocalJumpError(Ruby.java:3766)
at org.jruby.exceptions.JumpException$FlowControlException.buildException(JumpException.java:72)
at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:104)
at java.lang.Thread.run(Thread.java:745)
Tried it on webrick same results:
Exception in thread "Ruby-0-Thread-12: /Users/dennis/.rvm/rubies/jruby-1.7.24/lib/ruby/1.9/webrick/server.rb:180" java.lang.ArrayIndexOutOfBoundsException: -1
at org.jruby.runtime.ThreadContext.getCurrentFrame(ThreadContext.java:479)
at org.jruby.runtime.ThreadContext.getFrameName(ThreadContext.java:606)
at org.jruby.exceptions.RaiseException.doCallEventHook(RaiseException.java:235)
at org.jruby.exceptions.RaiseException.preRaise(RaiseException.java:212)
at org.jruby.exceptions.RaiseException.preRaise(RaiseException.java:196)
at org.jruby.exceptions.RaiseException.(RaiseException.java:141)
at org.jruby.Ruby.newLocalJumpError(Ruby.java:3766)
at org.jruby.exceptions.JumpException$FlowControlException.buildException(JumpException.java:72)
at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:104)
at java.lang.Thread.run(Thread.java:745)
Environment
Provide at least:
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
Other relevant info you may wish to add:
Gemfile:
ruby '1.9.3', :engine => 'jruby', :engine_version => '1.7.24'
gem "rails", "= 4.1.15"
gem "sequel", "4.24.0.6369d34f70988ff5e2d4489b876d1cc303accdc9"
gem 'fortitude', "0.9.5.831bd40aa5a5256194d782fac9b79b0967b400fc"
gem "formtastic", "
> 3.1.3"> 3.1.2"gem "rufus-scheduler", "
gem 'nokogiri', "1.6.8.rc3"
gem "ri_cal", "0.8.8.2d8b47fc4faf589b10d7ec1a090a78267384eab9"
gem "mail", :require => nil
gem "inherited_resources", "1.3.1.e4eb89595d1c58f2f7457c5dfb138398beedb8b8"
gem "bcrypt"
gem "uuidtools"
gem "jruby-openssl", "0.9.15"
gem "json"
gem "http_accept_language", "1.0.1.1.a75d7431d8bba418294b29d43dd8f546ebbffe23"
gem "excon"
gem "rest-client", "1.6.8.9fd53c1e063d89cf84db461d14ddf019f6a94628" # Remove CC-licensed master_shake.jpg
gem "tem-server-api", "
> 2.0.8"> 2.5.1"gem "activeresource-response"
gem "rubyzip", "1.1.7.72e98a666eab510dbb7f32d8a6094a80f02a0c8e"
gem "time_diff"
gem "json-schema", "
gem "tzinfo-data"
gem "activesupport-json_encoder"
gem "abstract", "1.0.0.d86eb2255aefb5c0ce4dd2351dbbf4b9e22264ad"
gem "erubis", "2.7.0.1.ed3659f9fdc6659f69fce047e9f57f0289d903d8"
gem "uglifier", "
> 2.7.1"> 2.1.2"gem "sass-rails"
gem "i18n-js", "
gem "compass-rails", "
> 2.0.0"> 1.0.0"gem "compass-blueprint", "
gem "therubyrhino"
Expected Behavior
We run a simple validation were sequel need to check for a require field , email in this case and gives and error messages attached to an associated object.
Actual Behavior
Instead of returning an error message or any backtrace in the rails log , I getting this exception above
The text was updated successfully, but these errors were encountered: