Skip to content

Commit bd21cc7

Browse files
committed
[GR-54305] Convert CrashAtIsFatal to an int.
PullRequest: graal/17832
2 parents 95133fc + 924fbf6 commit bd21cc7

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,11 @@
164164
import jdk.vm.ci.services.Services;
165165

166166
class LibGraalOptions {
167-
@Option(help = "Converts an exception triggered by the CrashAt option into a fatal error " +
167+
@Option(help = "If non-zero, converts an exception triggered by the CrashAt option into a fatal error " +
168168
"if a non-null pointer was passed in the _fatal option to JNI_CreateJavaVM. " +
169+
"The value of this option is the number of milliseconds to sleep before calling _fatal. " +
169170
"This option exists for the purpose of testing fatal error handling in libgraal.") //
170-
static final RuntimeOptionKey<Boolean> CrashAtIsFatal = new LibGraalRuntimeOptionKey<>(false);
171+
static final RuntimeOptionKey<Integer> CrashAtIsFatal = new LibGraalRuntimeOptionKey<>(0);
171172
@Option(help = "The fully qualified name of a no-arg, void, static method to be invoked " +
172173
"in HotSpot from libgraal when the libgraal isolate is being shutdown." +
173174
"This option exists for the purpose of testing callbacks in this context.") //
@@ -889,8 +890,8 @@ static OptionValues initializeOptions() {
889890
options.update(values);
890891
}
891892

892-
if (LibGraalOptions.CrashAtThrowsOOME.getValue() && LibGraalOptions.CrashAtIsFatal.getValue()) {
893-
throw new IllegalArgumentException("CrashAtThrowsOOME and CrashAtIsFatal cannot both be true");
893+
if (LibGraalOptions.CrashAtThrowsOOME.getValue() && LibGraalOptions.CrashAtIsFatal.getValue() != 0) {
894+
throw new IllegalArgumentException("CrashAtThrowsOOME and CrashAtIsFatal cannot both be enabled");
894895
}
895896

896897
return options;
@@ -939,9 +940,14 @@ private static boolean notifyCrash(String crashMessage) {
939940
// Remaining compilations should proceed so that test finishes quickly.
940941
return false;
941942
}
942-
} else if (LibGraalOptions.CrashAtIsFatal.getValue()) {
943+
} else if (LibGraalOptions.CrashAtIsFatal.getValue() != 0) {
943944
LogHandler handler = ImageSingletons.lookup(LogHandler.class);
944945
if (handler instanceof FunctionPointerLogHandler) {
946+
try {
947+
Thread.sleep(LibGraalOptions.CrashAtIsFatal.getValue());
948+
} catch (InterruptedException e) {
949+
// ignore
950+
}
945951
VMError.shouldNotReachHere(crashMessage);
946952
}
947953
// If changing this message, update the test for it in mx_vm_gate.py

vm/mx.vm/mx_vm_gate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _test_libgraal_fatal_error_handling():
239239
graalvm_home = mx_sdk_vm_impl.graalvm_home()
240240
vmargs = ['-XX:+PrintFlagsFinal',
241241
'-Djdk.libgraal.CrashAt=*',
242-
'-Djdk.libgraal.CrashAtIsFatal=true']
242+
'-Djdk.libgraal.CrashAtIsFatal=1']
243243
cmd = [join(graalvm_home, 'bin', 'java')] + vmargs + _get_CountUppercase_vmargs()
244244
out = mx.OutputCapture()
245245
scratch_dir = mkdtemp(dir='.')

0 commit comments

Comments
 (0)