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