Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
base: ffed1b848da4
Choose a base ref
...
head repository: jruby/jruby
compare: b17bee6636ff
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Dec 1, 2016

  1. Fix deadlock when tearing down runtime during debugging

    When trying to exit with a hard exit (exit!), runtime teardown is
    performed by the shutdown hook thread added in Main.internalRun(), which
    is run on a different thread.
    
    This poses a problem when using ruby-debug, as it grabs a lock while
    processing debug events [1], and thus if you try to exit! while trying to
    process debug events (for instance if you're debugging interactively
    with pry and you want to exit), you'll get a deadlock looking something
    like this:
    
    ```
    "Thread-1" - Thread t@11
       java.lang.Thread.State: BLOCKED
      at org.jruby.debug.DebugEventHook.eventHandler(DebugEventHook.java:91)
      - waiting to lock <3b88136f> (a org.jruby.debug.DebugEventHook) owned by "main" t@1
      at org.jruby.runtime.EventHook.event(EventHook.java:30)
      at org.jruby.Ruby.callEventHooks(Ruby.java:3179)
      at org.jruby.runtime.ThreadContext.trace(ThreadContext.java:652)
      (...)
      at org.jruby.RubyProc.call(RubyProc.java:249)
      at org.jruby.Ruby.tearDown(Ruby.java:3281)
      at org.jruby.Ruby.tearDown(Ruby.java:3254)
      at org.jruby.Main$1.run(Main.java:293)
    
       Locked ownable synchronizers:
      - None
    
    "main" - Thread t@1
       java.lang.Thread.State: WAITING
      at java.lang.Object.wait(Native Method)
      - waiting on <5579bb86> (a org.jruby.Main$1)
      at java.lang.Thread.join(Thread.java:1249)
      at java.lang.Thread.join(Thread.java:1323)
      at java.lang.ApplicationShutdownHooks.runHooks(ApplicationShutdownHooks.java:106)
      at java.lang.ApplicationShutdownHooks$1.run(ApplicationShutdownHooks.java:46)
      at java.lang.Shutdown.runHooks(Shutdown.java:123)
      at java.lang.Shutdown.sequence(Shutdown.java:167)
      at java.lang.Shutdown.exit(Shutdown.java:212)
      - locked <39d0fc85> (a java.lang.Class)
      at java.lang.Runtime.exit(Runtime.java:109)
      at java.lang.System.exit(System.java:971)
      at org.jruby.RubyKernel.exit(RubyKernel.java:708)
      at org.jruby.RubyKernel.exit_bang(RubyKernel.java:683)
      (...)
      at org.jruby.debug.DebugEventHook.eventHandler(DebugEventHook.java:97)
      - locked <3b88136f> (a org.jruby.debug.DebugEventHook)
      at org.jruby.runtime.EventHook.event(EventHook.java:30)
      at org.jruby.Ruby.callEventHooks(Ruby.java:3179)
      at org.jruby.runtime.ThreadContext.trace(ThreadContext.java:652)
      (...)
      at org.jruby.Main.main(Main.java:204)
    ```
    
    To fix this, we disable event hooks during teardown, so that code events
    during this period are not sent to the debugger.
    
    [1]: https://github.com/ruby-debug/ruby-debug/blob/master/src/org/jruby/debug/DebugEventHook.java#L91-L101
    ivoanjo committed Dec 1, 2016
    Copy the full SHA
    f9d704c View commit details
    Browse the repository at this point in the history

Commits on Dec 4, 2016

  1. Merge pull request #4352 from ivoanjo/fix-debug-teardown-deadlock

    Fix deadlock when tearing down runtime during debugging
    kares committed Dec 4, 2016
    Copy the full SHA
    b17bee6 View commit details
    Browse the repository at this point in the history