JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6553

Application continues running after throwing out of memory exception in Thread.

    Details

    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      When running an application with threads and Java throws an out of memory error the application continues instead of aborting. The Thread that ran out of memory "dies", a back trace is displayed, but the application continues running other threads.

      A work-around is to catch the exception then exit (re-raise also fails).

        Activity

        Hide
        Taylor Carpenter added a comment -

        FYI, jruby 1.7.0 dev (2012-03-17 693da51) also has this issue.

        Show
        Taylor Carpenter added a comment - FYI, jruby 1.7.0 dev (2012-03-17 693da51) also has this issue.
        Hide
        Wayne Walker added a comment - - edited

        This also affects 1.6.7.2 and 1.7.0.preview1.

        This is a crash problem and a crash in an undetectable manner (other threads continue, rescue actions don't work properly).

        That is, in order to make threaded applications work properly, a specialized begin/rescue/end needs to be added to every Thread created in a program, or failures will not be seen by the application.

        Since the community at large appears unaware of this bug, most threaded applications are much less robust than expected.

        Show
        Wayne Walker added a comment - - edited This also affects 1.6.7.2 and 1.7.0.preview1. This is a crash problem and a crash in an undetectable manner (other threads continue, rescue actions don't work properly). That is, in order to make threaded applications work properly, a specialized begin/rescue/end needs to be added to every Thread created in a program, or failures will not be seen by the application. Since the community at large appears unaware of this bug, most threaded applications are much less robust than expected.
        Hide
        Charles Oliver Nutter added a comment -

        The issue here is that we're not also propagating Errors when a thread dies. Will look into that and fix.

        Show
        Charles Oliver Nutter added a comment - The issue here is that we're not also propagating Errors when a thread dies. Will look into that and fix.
        Hide
        Charles Oliver Nutter added a comment -

        Ok, this fixes the issue by forcing Error throwables to be propagated on the main thread if abort_on_exception = true, but I'm using one of the forbidden java.lang.Thread methods, stop(Throwable). I don't feel too worried about this particular use, since an Error is usually a fatal event and we're just attempting to propagate it out (plus most people don't or shouldn't run shared JVMs with abort_on_exception = true), but I'm going to have someone else review.

        https://gist.github.com/3132731

        Will mark for 1.7.0pre2.

        Show
        Charles Oliver Nutter added a comment - Ok, this fixes the issue by forcing Error throwables to be propagated on the main thread if abort_on_exception = true, but I'm using one of the forbidden java.lang.Thread methods, stop(Throwable). I don't feel too worried about this particular use, since an Error is usually a fatal event and we're just attempting to propagate it out (plus most people don't or shouldn't run shared JVMs with abort_on_exception = true), but I'm going to have someone else review. https://gist.github.com/3132731 Will mark for 1.7.0pre2.
        Hide
        Charles Oliver Nutter added a comment -
        commit caa7f5ad7b8d8148384be33981f7cf3880377df0
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Tue Jul 24 12:36:42 2012 -0500
        
            Fix JRUBY-6553
            
            Application continues running after throwing out of memory exception in Thread.
            
            I'm going with what some might see as a dubious fix: using
            java.lang.Thread.stop(Throwable) to propagate the error to the
            main thread. My justification is as follows:
            
            * This only applies to Error cases like memory or stack, which are
            usually fatal anyway (and even when not fatal, are probably a
            sign of a major problem).
            * It also only happens with abort_on_exception=true, which nobody
            sets unless they *intend* for the process to exit on Thread-borne
            errors.
            
            The effect of this change is that when abort_on_exception=true is
            set, Java Errors will also propagate to the main thread, likely
            terminating the process.
        
        :100644 100644 99acb63... 32fb95e... M	src/org/jruby/RubyThread.java
        :100644 100644 b26dc09... cdb6c1f... M	src/org/jruby/internal/runtime/RubyRunnable.java
        
        Show
        Charles Oliver Nutter added a comment - commit caa7f5ad7b8d8148384be33981f7cf3880377df0 Author: Charles Oliver Nutter <headius@headius.com> Date: Tue Jul 24 12:36:42 2012 -0500 Fix JRUBY-6553 Application continues running after throwing out of memory exception in Thread. I'm going with what some might see as a dubious fix: using java.lang.Thread.stop(Throwable) to propagate the error to the main thread. My justification is as follows: * This only applies to Error cases like memory or stack, which are usually fatal anyway (and even when not fatal, are probably a sign of a major problem). * It also only happens with abort_on_exception=true, which nobody sets unless they *intend* for the process to exit on Thread-borne errors. The effect of this change is that when abort_on_exception=true is set, Java Errors will also propagate to the main thread, likely terminating the process. :100644 100644 99acb63... 32fb95e... M src/org/jruby/RubyThread.java :100644 100644 b26dc09... cdb6c1f... M src/org/jruby/internal/runtime/RubyRunnable.java

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Taylor Carpenter
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: