Rails:method_missing 导致 StackOverflowError
Rails: method_missing leads to StackOverflowError
在开发模式下,在 Rails 服务器 运行 上触发对 method_missing 的调用时,它会以 WhosebugError
结束。这是 JRuby 环境中的 Rails5。我们这里没有使用多线程。
行为可以总结如下:
- 发生Whosebug的class是我们自己写的。实施
def method_missing
并从那里引发正确的行为(例如 fail 'oh noes.'
将打印预期的错误)。
- 在
method_missing
实现中调用 super(*args) 将再次导致 WhosebugError
。
- 在
super
正上方调用 debugger
有效,键入 next
显示以下调用是:
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
- [Whosebug]
- 在调试 shell 中(如第 3 点),任何通过
backtrace
或 info stack
获取跟踪的尝试都将导致 Whosebug。
- None 服务器在测试或生产环境中启动时会发生这种情况。
我们看到 this commit 中的 Rails 中删除了一些代码。事实上,将删除的代码放回(仅用于测试目的)可以解决问题。
您认为这是一个 rails 错误吗?
可能在 https://github.com/rails/rails/issues/27481 中解决。
似乎是一个 jruby 错误。
在开发模式下,在 Rails 服务器 运行 上触发对 method_missing 的调用时,它会以 WhosebugError
结束。这是 JRuby 环境中的 Rails5。我们这里没有使用多线程。
行为可以总结如下:
- 发生Whosebug的class是我们自己写的。实施
def method_missing
并从那里引发正确的行为(例如fail 'oh noes.'
将打印预期的错误)。 - 在
method_missing
实现中调用 super(*args) 将再次导致WhosebugError
。 - 在
super
正上方调用debugger
有效,键入next
显示以下调用是: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
- [Whosebug]
- 在调试 shell 中(如第 3 点),任何通过
backtrace
或info stack
获取跟踪的尝试都将导致 Whosebug。 - None 服务器在测试或生产环境中启动时会发生这种情况。
我们看到 this commit 中的 Rails 中删除了一些代码。事实上,将删除的代码放回(仅用于测试目的)可以解决问题。
您认为这是一个 rails 错误吗?
可能在 https://github.com/rails/rails/issues/27481 中解决。 似乎是一个 jruby 错误。