Skip to content

Commit 7daaa6b

Browse files
committed
[GR-24617] Re-raise the signal if the thread to handle it cannot be attached
1 parent d6e56aa commit 7daaa6b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/main/java/org/truffleruby/core/VMPrimitiveNodes.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import java.io.PrintStream;
4141
import java.util.Map.Entry;
4242

43-
import com.oracle.truffle.api.CompilerDirectives;
4443
import org.jcodings.specific.ASCIIEncoding;
4544
import org.jcodings.specific.UTF8Encoding;
4645
import org.truffleruby.Layouts;
@@ -57,8 +56,8 @@
5756
import org.truffleruby.core.proc.ProcOperations;
5857
import org.truffleruby.core.rope.CodeRange;
5958
import org.truffleruby.core.string.StringNodes.MakeStringNode;
60-
import org.truffleruby.core.thread.ThreadManager;
6159
import org.truffleruby.core.string.StringOperations;
60+
import org.truffleruby.core.thread.ThreadManager;
6261
import org.truffleruby.language.backtrace.Backtrace;
6362
import org.truffleruby.language.control.ExitException;
6463
import org.truffleruby.language.control.RaiseException;
@@ -70,6 +69,7 @@
7069
import org.truffleruby.language.yield.YieldNode;
7170
import org.truffleruby.platform.Signals;
7271

72+
import com.oracle.truffle.api.CompilerDirectives;
7373
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
7474
import com.oracle.truffle.api.TruffleContext;
7575
import com.oracle.truffle.api.dsl.Cached;
@@ -79,6 +79,8 @@
7979
import com.oracle.truffle.api.profiles.BranchProfile;
8080
import com.oracle.truffle.api.profiles.ConditionProfile;
8181

82+
import sun.misc.Signal;
83+
8284
@CoreModule(value = "VMPrimitives", isClass = true)
8385
public abstract class VMPrimitiveNodes {
8486

@@ -262,8 +264,13 @@ protected boolean watchSignalProc(DynamicObject signalName, DynamicObject action
262264
final PrintStream printStream = new PrintStream(context.getEnv().err(), true);
263265
printStream.println(
264266
"[ruby] SEVERE: signal " + signal +
265-
" caught but can't create a thread to handle it so ignoring and restoring the default handler");
267+
" caught but can't attach a thread to handle it so restoring the default handler and re-raising the signal");
266268
Signals.restoreDefaultHandler(signal);
269+
try {
270+
Signal.raise(new Signal(signal));
271+
} catch (IllegalArgumentException illegalArgumentException) {
272+
illegalArgumentException.printStackTrace(printStream);
273+
}
267274
return;
268275
}
269276
try {

0 commit comments

Comments
 (0)