Skip to content

Commit 237ab7c

Browse files
committed
Unblock other Fibers when a Fiber thread gets an uncaught exception
1 parent 460bb6a commit 237ab7c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/org/truffleruby/core/thread/ThreadManager.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,14 @@ private static Thread.UncaughtExceptionHandler uncaughtExceptionHandler(RubyFibe
189189
return (javaThread, throwable) -> {
190190
printInternalError(throwable);
191191
try {
192+
fiber.uncaughtException = throwable;
193+
194+
// If an uncaught exception happens, we already left the context, so it is safe to let other Fibers run
195+
192196
// the Fiber is not yet initialized, unblock the caller and rethrow the exception to it
193-
if (fiber.initializedLatch.getCount() > 0) {
194-
fiber.uncaughtException = throwable;
195-
fiber.initializedLatch.countDown();
196-
}
197+
fiber.initializedLatch.countDown();
198+
// the Fiber thread is dying, unblock the caller
199+
fiber.finishedLatch.countDown();
197200
} catch (Throwable t) { // exception inside this UncaughtExceptionHandler
198201
t.initCause(throwable);
199202
printInternalError(t);

0 commit comments

Comments
 (0)