@@ -169,7 +169,7 @@ private Thread createFiberJavaThread(Runnable runnable) {
169
169
return thread ;
170
170
}
171
171
172
- private Thread createJavaThread (Runnable runnable , RubyFiber fiber ) {
172
+ private Thread createJavaThread (Runnable runnable , RubyThread rubyThread ) {
173
173
if (context .getOptions ().SINGLE_THREADED ) {
174
174
throw new RaiseException (
175
175
context ,
@@ -182,7 +182,8 @@ private Thread createJavaThread(Runnable runnable, RubyFiber fiber) {
182
182
183
183
final Thread thread = context .getEnv ().createThread (runnable );
184
184
rubyManagedThreads .add (thread ); // need to be set before initializeThread()
185
- thread .setUncaughtExceptionHandler (uncaughtExceptionHandler (fiber ));
185
+ javaThreadToRubyThread .put (thread , rubyThread ); // need to be set before initializeThread()
186
+ thread .setUncaughtExceptionHandler (uncaughtExceptionHandler (rubyThread .getRootFiber ()));
186
187
return thread ;
187
188
}
188
189
@@ -289,7 +290,7 @@ public void initialize(RubyThread rubyThread, Node currentNode, String info, Str
289
290
rubyThread .sourceLocation = info ;
290
291
final RubyFiber rootFiber = rubyThread .getRootFiber ();
291
292
292
- final Thread thread = createJavaThread (() -> threadMain (rubyThread , currentNode , task ), rootFiber );
293
+ final Thread thread = createJavaThread (() -> threadMain (rubyThread , currentNode , task ), rubyThread );
293
294
thread .setName (NAME_PREFIX + " id=" + thread .getId () + " from " + info );
294
295
rubyThread .thread = thread ;
295
296
javaThreadToRubyThread .put (thread , rubyThread );
0 commit comments