Skip to content

[GR-65416] Use -R:+EnableSignalHandling -R:+InstallSegfaultHandler instead of forcing them in the thin launchers #11329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/mx.sdk/mx_sdk_vm_impl.py
Original file line number Diff line number Diff line change
@@ -1417,6 +1417,8 @@ def contents(self):

if isinstance(image_config, mx_sdk.LauncherConfig) or (isinstance(image_config, mx_sdk.LanguageLibraryConfig) and image_config.launchers):
build_args += [
'-R:+EnableSignalHandling',
'-R:+InstallSegfaultHandler',
'--enable-monitoring=jvmstat,heapdump,jfr,threaddump',
] + svm_experimental_options([
'-H:+InstallExitHandlers',
2 changes: 1 addition & 1 deletion sdk/mx.sdk/mx_sdk_vm_ng.py
Original file line number Diff line number Diff line change
@@ -376,7 +376,7 @@ class LanguageLibraryProject(NativeImageLibraryProject):
def get_build_args(self):
build_args = super().get_build_args()[:]

# Signals flags, the first 2 are also set in AbstractLanguageLauncher but better to be explicit
# Signals flags
build_args += [
'-R:+EnableSignalHandling',
'-R:+InstallSegfaultHandler',
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
@@ -48,7 +48,6 @@
import java.util.List;
import java.util.Map;

import org.graalvm.nativeimage.RuntimeOptions;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Engine;
import org.graalvm.polyglot.Language;
@@ -150,12 +149,6 @@ protected final void launch(String[] args) {
* @throws Exception if no launcher constructor has been set.
*/
public static void runLauncher(byte[][] optionVarsArgs, byte[][] args, int argc, long argv, boolean relaunch) throws Exception {
if (isAOT()) {
// enable signal handling for the launcher
RuntimeOptions.set("EnableSignalHandling", true);
RuntimeOptions.set("InstallSegfaultHandler", true);
}

if (LAUNCHER_CTOR == null) {
throw new Exception("Launcher constructor has not been set.");
}
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ private static boolean isFirst() {
public abstract class SubstrateSegfaultHandler {
public static class Options {
@Option(help = "Install segfault handler that prints register contents and full Java stacktrace. Default: enabled for an executable, disabled for a shared library, disabled when EnableSignalHandling is disabled.")//
static final RuntimeOptionKey<Boolean> InstallSegfaultHandler = new RuntimeOptionKey<>(null);
public static final RuntimeOptionKey<Boolean> InstallSegfaultHandler = new RuntimeOptionKey<>(null);
}

private static final long MARKER_VALUE = 0x0123456789ABCDEFL;
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
import java.lang.reflect.Array;
import java.nio.ByteBuffer;

import com.oracle.svm.core.SubstrateSegfaultHandler;
import org.graalvm.collections.EconomicMap;
import org.graalvm.nativeimage.CurrentIsolate;
import org.graalvm.nativeimage.Isolates;
@@ -127,6 +128,10 @@ private static void appendOptionsRelevantForCompilationIsolates(CreateIsolatePar

/* Compilation isolates do the reference handling manually to avoid the extra thread. */
appendArgument(builder, SubstrateOptions.ConcealedOptions.AutomaticReferenceHandling, false);

/* Disable signal handling for compilation isolates. */
appendArgument(builder, SubstrateOptions.EnableSignalHandling, false);
appendArgument(builder, SubstrateSegfaultHandler.Options.InstallSegfaultHandler, false);
}

private static void appendOptionsExplicitlySetForCompilationIsolates(CreateIsolateParameters.Builder builder) {