Skip to content

Commit d019d3d

Browse files
committed
[GR-64787] Enable --install-exit-handlers by default and deprecate the option.
PullRequest: graal/20739
2 parents 5f0c09d + 38f70ae commit d019d3d

File tree

11 files changed

+28
-44
lines changed

11 files changed

+28
-44
lines changed

docs/reference-manual/native-image/BuildOptions.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ Run `native-image --help` for help on build options.
5959
* `--gc=<value>`: select a Native Image garbage collector implementation. Allowed options for `<value>` are: `G1` for G1 garbage collector (not available in GraalVM Community Edition); `epsilon` for Epsilon garbage collector; `serial` for Serial garbage collector (default).
6060
* `--initialize-at-build-time`: a comma-separated list of packages and classes (and implicitly all of their superclasses) that are initialized during generation of a native executable. An empty string designates all packages.
6161
* `--initialize-at-run-time`: a comma-separated list of packages and classes (and implicitly all of their subclasses) that must be initialized at run time and not during generation. An empty string is currently not supported.
62-
* `--install-exit-handlers`: provide `java.lang.Terminator` exit handlers
6362
* `--libc`: select the `libc` implementation to use. Available implementations are `glibc`, `musl`, `bionic`.
6463
* `--link-at-build-time`: require types to be fully defined at native executable build time. If used without arguments, all classes in scope of the option are required to be fully defined.
6564
* `--link-at-build-time-paths`: require all types in given class or module path entries to be fully defined at native executable build time

docs/reference-manual/native-image/Compatibility.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ Native Image implements some Java features differently to the Java VM.
5151

5252
`java.lang.System#setSecurityManager(SecurityManager)` invoked with a non-null argument throws a `java.lang.SecurityException` if `-Djava.security.manager` is set to anything but `disallow` at program startup.
5353

54-
### Signal Handlers
55-
56-
Registering a signal handler requires a new thread to start that handles the signal and invokes shutdown hooks.
57-
By default, no signal handlers are registered when building a native image, unless they are registered explicitly by the user.
58-
For example, it is not recommended to register the default signal handlers when building a shared library, but it is desirable to include signal handlers when building a native executable for containerized environments, such as Docker containers.
59-
60-
To register the default signal handlers, pass the `--install-exit-handlers` option to the `native-image` builder.
61-
This option gives you the same signal handlers as a Java VM.
62-
6354
### Class Initializers
6455

6556
By default, classes are initialized at run time.

docs/reference-manual/native-image/guides/troubleshoot-run-time-errors.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,19 @@ Otherwise, the `System.getProperty("java.home")` call will return a `null` value
4747
Try enabling all URL protocols on-demand at build time: `--enable-url-protocols=<protocols>`.
4848
To enable the HTTPS support only, pass `--enable-https`.
4949

50-
### 4. Enable Signal Handling
51-
52-
If your application is using signal handling or the `java.lang.Terminator` exit handlers, provide the option `--install-exit-handlers` option at build time.
53-
54-
### 5. Include All Charsets and Locales
50+
### 4. Include All Charsets and Locales
5551

5652
Other handy options are `-H:+AddAllCharsets` to add charsets support, and `-H:+IncludeAllLocales` to pre-initialize support for locale-sensitive behavior in the `java.util` and `java.text` packages.
5753
Pass those options at build time.
5854
This might increase the size of the resulting binary.
5955

60-
### 6. Add Missing Security Providers
56+
### 5. Add Missing Security Providers
6157

6258
If your application is using Security Providers, try to pre-initialize security providers by passing the option `-H:AdditionalSecurityProviders=<list-of-providers>` at build time.
6359
Here is a list of all JDK security providers to choose from:
6460
`sun.security.provider.Sun,sun.security.rsa.SunRsaSign,sun.security.ec.SunEC,sun.security.ssl.SunJSSE,com.sun.crypto.provider.SunJCE,sun.security.jgss.SunProvider,com.sun.security.sasl.Provider,org.jcp.xml.dsig.internal.dom.XMLDSigRI,sun.security.smartcardio.SunPCSC,sun.security.provider.certpath.ldap.JdkLDAP,com.sun.security.sasl.gsskerb.JdkSASL`.
6561

66-
### 7. File a Native Image Run-Time Issue
62+
### 6. File a Native Image Run-Time Issue
6763

6864
Only if you tried all the above suggestions, file a [Native Image Run-Time Issue Report](https://github.com/oracle/graal/issues/new?assignees=&labels=native-image%2Cbug%2Crun-time&projects=&template=1_1_native_image_run_time_bug_report.yml&title=%5BNative+Image%5D+) at GitHub, filling out the necessary information.
6965

sdk/mx.sdk/mx_sdk_benchmark.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,6 @@ def run_stage_instrument_run(self):
14821482
mx.abort(
14831483
f"Profile file {self.config.profile_path} does not exist "
14841484
f"even though the instrument run terminated successfully with exit code 0. "
1485-
f"Try adding the '--install-exit-handlers' build option if it is not present."
14861485
)
14871486
print(f"Profile file {self.config.profile_path} sha1 is {mx.sha1OfFile(self.config.profile_path)}")
14881487
self._ensureSamplesAreInProfile(self.config.profile_path)

sdk/mx.sdk/mx_sdk_vm_impl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,6 @@ def contents(self):
14171417

14181418
if isinstance(image_config, mx_sdk.LauncherConfig) or (isinstance(image_config, mx_sdk.LanguageLibraryConfig) and image_config.launchers):
14191419
build_args += [
1420-
'--install-exit-handlers',
14211420
'--enable-monitoring=jvmstat,heapdump,jfr,threaddump',
14221421
] + svm_experimental_options([
14231422
'-H:+DumpRuntimeCompilationOnSignal',

sdk/mx.sdk/mx_sdk_vm_ng.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,17 @@ def get_build_args(self):
380380
build_args += [
381381
'-R:+EnableSignalHandling',
382382
'-R:+InstallSegfaultHandler',
383-
'--install-exit-handlers',
384-
]
383+
] + mx_sdk_vm_impl.svm_experimental_options(['-H:+InstallExitHandlers'])
385384

386385
# Monitoring flags
387386
if get_bootstrap_graalvm_version() >= mx.VersionSpec("24.0"):
388387
build_args += ['--enable-monitoring=jvmstat,heapdump,jfr,threaddump']
389388
else:
390389
build_args += ['--enable-monitoring=jvmstat,heapdump,jfr']
391-
build_args += ['-H:+UnlockExperimentalVMOptions', '-H:+DumpThreadStacksOnSignal', '-H:-UnlockExperimentalVMOptions']
392-
build_args += [
393-
'-H:+UnlockExperimentalVMOptions', '-H:+DumpRuntimeCompilationOnSignal', '-H:-UnlockExperimentalVMOptions',
394-
'-R:-UsePerfData', # See GR-25329, reduces startup instructions significantly
395-
]
390+
build_args += mx_sdk_vm_impl.svm_experimental_options(['-H:+DumpThreadStacksOnSignal', '-H:+DumpRuntimeCompilationOnSignal'])
391+
build_args += [
392+
'-R:-UsePerfData', # See GR-25329, reduces startup instructions significantly
393+
]
396394

397395
return build_args
398396

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
Args = --enable-url-protocols=http,https \
2-
--install-exit-handlers \
32
--initialize-at-build-time=org.graalvm.maven.downloader.OptionProperties \
43
--initialize-at-run-time=org.graalvm.maven.downloader.Main,org.graalvm.maven.downloader.MVNDownloader,org.graalvm.maven.downloader.Main$Arguments,org.graalvm.maven.downloader.MVNDownloader$DeleteDownloadDir

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This changelog summarizes major changes to GraalVM Native Image.
2424
* (GR-59869) Implemented initial optimization of Java Vector API (JEP 338) operations in native images. See the compiler changelog for more details.
2525
* (GR-63268) Reflection and JNI queries do not require metadata entries to throw the expected JDK exception when querying a class that doesn't exist under `--exact-reachability-metadata` if the query cannot possibly be a valid class name
2626
* (GR-60208) Adds the Tracing Agent support for applications using the Foreign Function & Memory (FFM) API. The agent generates FFM configuration in _foreign-config.json_. Additionally, support for FFM configurations has been added to the `native-image-configure` tool.
27+
* (GR-64787) Enable `--install-exit-handlers` by default for executables and deprecate the option. If shared libraries were using this flag, the same functionality can be restored by using `-H:+InstallJavaExitHandlersForSharedLibrary`.
2728
* (GR-47881) Remove the total number of loaded types, fields, and methods from the build output, deprecated these metrics in the build output schema, and removed already deprecated build output metrics.
2829

2930
## GraalVM for JDK 24 (Internal Version 24.2.0)

substratevm/mx.substratevm/mx_substratevm_benchmark.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,6 @@ def extra_run_arg(self, benchmark, args, image_run_args):
369369
# Added by BaristaNativeImageCommand
370370
return []
371371

372-
def extra_image_build_argument(self, benchmark, args):
373-
return [
374-
"--install-exit-handlers"
375-
] + super().extra_image_build_argument(benchmark, args)
376-
377372
def run(self, benchmarks, bmSuiteArgs) -> mx_benchmark.DataPoints:
378373
return self.intercept_run(super(), benchmarks, bmSuiteArgs)
379374

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateExitHandlerFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
public class SubstrateExitHandlerFeature implements InternalFeature {
3535
@Override
3636
public void beforeAnalysis(BeforeAnalysisAccess access) {
37-
if (SubstrateOptions.needsExitHandlers()) {
37+
if (SubstrateOptions.InstallExitHandlers.getValue()) {
3838
RuntimeSupport.getRuntimeSupport().addStartupHook(new SubstrateExitHandlerStartupHook());
3939
}
4040
}
@@ -43,7 +43,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
4343
final class SubstrateExitHandlerStartupHook implements RuntimeSupport.Hook {
4444
@Override
4545
public void execute(boolean isFirstIsolate) {
46-
if (isFirstIsolate) {
46+
if (SubstrateOptions.EnableSignalHandling.getValue() && isFirstIsolate) {
4747
Target_java_lang_Terminator.setup();
4848
}
4949
}

0 commit comments

Comments
 (0)