Rescue StandardError rescues Java errors #1696

grddev opened this Issue May 14, 2014 · 2 comments


None yet

4 participants

grddev commented May 14, 2014

The following example program prints [:error, java.lang.OutOfMemoryError: Java heap space], and exits with zero exit code, although I would have expected it not to

  str = 'xxx'
  loop do
    str *= 2;
rescue => e
  p [:error, e]
iconara commented May 14, 2014

To me this is a major issue. This means that an application that contains rescue => e cannot be relied on to behave well under error conditions.

This is what Java says about java.lang.Error:

An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.

For a long time we've known that rescue Exception rescued these errors, but it seems like this was introduced in 1.7.1 (this is the commit: 6b13c46), and we didn't notice until now.

If we send a patch, can we get this fixed in 1.7.13?

headius commented May 14, 2014

This is a bug. We do rescue Throwable for Object and Exception, but I don't think we should be doing it for StandardError...or StandardError should correspond to something like non-Error/RuntimeException descendants of Throwable.

@jrubyci jrubyci pushed a commit that closed this issue May 21, 2014
@grddev grddev Do not rescue java.lang.Error using StandardError
This in effect injects java.lang.Error as a subclass of Ruby Exception,
instead of StandardError as was previously the case.

This fixes #1696
@jrubyci jrubyci closed this in 63eefe6 May 21, 2014
@enebo enebo added this to the JRuby 1.7.13 milestone May 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment