File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
src/main/java/org/truffleruby/core/fiber Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 14
14
import java .util .concurrent .CountDownLatch ;
15
15
16
16
import com .oracle .truffle .api .TruffleContext ;
17
+ import com .oracle .truffle .api .TruffleSafepoint ;
17
18
import org .truffleruby .RubyContext ;
18
19
import org .truffleruby .RubyLanguage ;
19
20
import org .truffleruby .core .DummyNode ;
@@ -356,11 +357,19 @@ public void killOtherFibers() {
356
357
357
358
// This method might not be executed on the rootFiber Java Thread but possibly on another Java Thread.
358
359
359
- final TruffleContext truffleContext = context .getEnv ().getContext ();
360
- context .getThreadManager ().leaveAndEnter (truffleContext , DummyNode .INSTANCE , () -> {
361
- doKillOtherFibers ();
362
- return BlockingAction .SUCCESS ;
363
- });
360
+ // Disallow side-effecting safepoints, the current thread is cleaning up and terminating.
361
+ // It can no longer process any exception or guest code.
362
+ final TruffleSafepoint safepoint = TruffleSafepoint .getCurrent ();
363
+ boolean allowSideEffects = safepoint .setAllowSideEffects (false );
364
+ try {
365
+ final TruffleContext truffleContext = context .getEnv ().getContext ();
366
+ context .getThreadManager ().leaveAndEnter (truffleContext , DummyNode .INSTANCE , () -> {
367
+ doKillOtherFibers ();
368
+ return BlockingAction .SUCCESS ;
369
+ });
370
+ } finally {
371
+ safepoint .setAllowSideEffects (allowSideEffects );
372
+ }
364
373
}
365
374
366
375
private void doKillOtherFibers () {
You can’t perform that action at this time.
0 commit comments