Skip to content

Commit

Permalink
Fix shutdown deadlock when a shutdown hook crashes - halt() instead o…
Browse files Browse the repository at this point in the history
…f exit().

See associated bug for more details.

--
MOS_MIGRATED_REVID=86708715
  • Loading branch information
ericfelly authored and hanwen committed Feb 19, 2015
1 parent 48746df commit aff6fd7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public static void handleCrash(Throwable throwable, String... args) {
// We don't call runtime#shutDown() here because all it does is shut down the modules, and who
// knows if they can be trusted.
}
System.exit(exitCode);
// Avoid shutdown deadlock issues: If an application shutdown hook crashes, it will trigger our
// Blaze crash handler (this method). Calling System#exit() here, would therefore induce a
// deadlock. This call would block on the shutdown sequence completing, but the shutdown
// sequence would in turn be blocked on this thread finishing. Instead, exit fast via halt().
Runtime.getRuntime().halt(exitCode);
}

private static void printThrowableTo(OutErr outErr, Throwable e) {
Expand Down

0 comments on commit aff6fd7

Please sign in to comment.