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

'Thread.main.exit!' and/or 'Kernel.exit!' does not work under certain circumstances

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.0.0, JRuby 1.1b1
    • Fix Version/s: JRuby 1.0.2, JRuby 1.1b1
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      Linux
    • Number of attachments :
      4

      Description

      I'm trying to solve problem why classic debugger in debug-commons does not exit under Windows. It is caused by the fact that 'Kernel.exit!' does not exit the underlaying process. As trying to reproduce with simple test-case I've got to the following one under Linux which might be related to the Windows problem. Not sure, the one under Windows might be different.

      Following code exit under C Ruby but not under JRuby (running Linux). It might cause by the 'next' call somehow .

       
      terminator = Thread.new do
        sleep 2
        puts 'exit'
        exit!
      end
      Kernel.module_eval(<<-"end;"
            alias_method(:debug_commons_set_trace_func, :set_trace_func)
            def set_trace_func(proc)
              raise "Cannot call 'set_trace_func' method during debugging session."
            end
        end;
      )
      debug_commons_set_trace_func(lambda do |_, _, _, _, _, _|
        next if Thread.current == terminator
        loop do
          puts Thread.current.object_id
          sleep 1
        end
      end)
      p "whatever...."
      
      1. exit_rev2.trunk.patch
        6 kB
        Peter Brant
      2. exit.jruby-1_0.patch
        3 kB
        Pon Hwa Lin
      3. exit.patch
        6 kB
        Peter Brant
      4. exit.trunk.patch
        6 kB
        Pon Hwa Lin

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        This patch looks great...I have no problem applying it. But it's gotten stale

        Would it be possible to get an updated patch for 1.0.2 and 1.1? And 1.0.2 is on the hot seat right now, we need to close the door on changes really soon.

        Show
        Charles Oliver Nutter added a comment - This patch looks great...I have no problem applying it. But it's gotten stale Would it be possible to get an updated patch for 1.0.2 and 1.1? And 1.0.2 is on the hot seat right now, we need to close the door on changes really soon .
        Hide
        Pon Hwa Lin added a comment -

        I've updated the patches supplied by pbrant for both trunk and jruby-1_0, but I'm not familiar enough with the jruby internals to be sure about what work, if any, needs to be done to backport the compiler-related changes for 1.0.2.

        Both the trunk and jruby-1_0 patches were built and tested against r4781 on ubuntu 7.10 w/JDK 1.6.0_03.

        Show
        Pon Hwa Lin added a comment - I've updated the patches supplied by pbrant for both trunk and jruby-1_0, but I'm not familiar enough with the jruby internals to be sure about what work, if any, needs to be done to backport the compiler-related changes for 1.0.2. Both the trunk and jruby-1_0 patches were built and tested against r4781 on ubuntu 7.10 w/JDK 1.6.0_03.
        Hide
        Peter Brant added a comment -

        Slightly cleaned up version of current trunk patch that uses isKindOf() vs. ==. Hopefully more future proof.

        Show
        Peter Brant added a comment - Slightly cleaned up version of current trunk patch that uses isKindOf() vs. ==. Hopefully more future proof.
        Hide
        Charles Oliver Nutter added a comment -

        Patch looks pretty clean, so I've applied it to trunk and 1.0 branch. If someone can think of a good way to write a test for this, that would be very nice. Please?

        Show
        Charles Oliver Nutter added a comment - Patch looks pretty clean, so I've applied it to trunk and 1.0 branch. If someone can think of a good way to write a test for this, that would be very nice. Please?
        Hide
        Charles Oliver Nutter added a comment -

        BTW, Pon Hwa Lin: No compiler changes were need in 1.0.2, since it did not compile any try/catch/rescue/ensure code as 1.1 does.

        Show
        Charles Oliver Nutter added a comment - BTW, Pon Hwa Lin: No compiler changes were need in 1.0.2, since it did not compile any try/catch/rescue/ensure code as 1.1 does.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: