-
-
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
NullPointerException in Helpers.invokedynamic #3608
Comments
would be interesting to know some context (if you have) around the piece of .rb code this comes from. |
Recapping a bit from the actual code... The line in question is here: public static IRubyObject invokedynamic(ThreadContext context, IRubyObject self, MethodNames method, IRubyObject arg0) {
RubyClass metaclass = self.getMetaClass(); <<<<<
String name = method.realName();
return getMethodCached(context, metaclass, method.ordinal(), name).call(context, self, metaclass, name, arg0);
} The only way we'd have a NPE at this point would be if self were null, which is a serious bug somewhere. As you have seen, the self value here ultimately is coming out of an array during an public boolean includes(ThreadContext context, IRubyObject item) {
int myBegin = this.begin;
int end = myBegin + realLength;
IRubyObject[] values = this.values;
for (int i = myBegin; i < end; i++) {
final IRubyObject value = safeArrayRef(values, i);
if (equalInternal(context, value, item)) return true; <<<<<
}
return false;
} In order for there to be a loose null in an Array, one of two things would have to happen:
I agree with your assessment, and my guess is that there's a concurrency problem here. Unfortunately it's hard to find these issues when there's a bunch of interpreter frames mixed in. If you have a system where this shows up, you might add some exception handling around that line and re-raise a Ruby exception like this: try {
// that line that NPEs
} catch (NullPointerException npe) {
throw context.runtime.newRuntimeError("NPE!!!");
} Throwing a Ruby error will propagate out better and include a Ruby backtrace that should help figure out where this is happening. Sorry we can't be more help, but we really need to know where the concurrent access is happening. Without that information, and since this seems likely to be a concurrency issue within your application (or the libraries it uses) I'm going to close this for now. Please, please reopen if you are able to provide more information, or if the error becomes easily reproducible. We want to help! |
I went through the same code as headius, to no avail. But, luckily later on when this problem happened again, we got a nice error in the form So this is probably solved and thanks. |
@jmiettinen In the future we will hopefully be able to explore an Array impl that's more robust under concurrency, but for now I'm glad you got a proper error instead of an NPE. Good to see you again at Jfokus! |
We have a Rails application running on Tomcat. From time to time, after a restart, loading some views will always fail with the following error:
As restarting usually helps and I haven't been able to reproduce this, I am guessing this is some kind of concurrency problem. Can
RubyArray
havenull
s in it as a result of concurrent access to it from the application code?The line numbers are for version 1.7.23.
The text was updated successfully, but these errors were encountered: