Rails: method_missing leads to StackOverflowError

139 views Asked by At

When triggering a call to method_missing on a Rails server running in development mode, it dies with a StackOverflowError. This is a Rails5 on JRuby environment. We are not using multi-threading here.

The behavior can be summarized as follows:

  1. The class in which the StackOverflow occurs was written by ourselves. Implementing def method_missing and raising from there results in correct behavior (e.g. fail 'oh noes.' will print the expected error).
  2. Calling super(*args) in the method_missing implemented will result in a StackOverflowError again.
  3. Calling debugger right above super works and typing next reveals that the following calls are:
    • gems/actionpack-5.0.1.rc2/lib/action_controller/metal/rescue.rb:22
      • request.env['action_dispatch.show_detailed_exceptions'] ||= show_detailed_exceptions?
    • gems/actionpack-5.0.1.rc2/lib/action_controller/metal/rescue.rb:23
      • rescue_with_handler(exception) || raise
    • [StackOverflow]
  4. In the debug shell (as in point 3), any attempt to get a trace via backtrace or info stack will result in a StackOverflow.
  5. None of this happens when the server is started in test or production environment.

We saw that some code was removed in Rails in this commit. Indeed, putting the deleted code back in (for testing purposes only) resolves the problem.

Do you think this is a rails bug?

1

There are 1 answers

1
B.G. On BEST ANSWER

Possibly solved in https://github.com/rails/rails/issues/27481. Seems like a jruby bug.