RFR: 8291569: Consider removing JNI checks for signals SIGPIPE and SIGXFSZ [v2]

Thomas Stuefe stuefe at openjdk.org
Tue Jan 24 13:27:06 UTC 2023


On Tue, 24 Jan 2023 13:06:07 GMT, Robbin Ehn <rehn at openjdk.org> wrote:

> I'm wondering if the user have communicated this to the VM by using the proper option, but are starting without the signal handlers yet installed. E.g. The user starts the VM and at later stage while doing additional class loading a dynamic library is loaded which installs SIGPIPE handler. (it can also be JVM TI agent or so which is later unloaded) When this code no longer is relevant the user calls down to that library to shutdown, it thus removes it's signal handlers.
> 
> I have not seen that you must install your handler before CreateVM, but maybe you must? Again a bit confused by this, maybe I understand it wrong.

To my understanding, this scenario should work if signal handling is set up correctly and completely (including pre-loading libjsig).

There are two phases:
- user handler installed before hotspot signal init: we store the user handler in hotspot for chaining.
- user handler installed after hotspot signal init: if the user uses libjsig correctly (https://docs.oracle.com/javase/8/docs/technotes/guides/vm/signal-chaining.html) it will have been preloaded and we will intercept the sigaction() call. We then leave our own signal handler installed but store the user handler in the libjsig.

When we process a signal and signal chaining is on, we call the chained handler, with the one from the libjsig having precedence - https://github.com/openjdk/jdk/blob/1a6ac606cd430d86acede05e9caeaddec57c50d0/src/hotspot/os/posix/signals_posix.cpp#L381-L394

And signal handler de-installation should just work accordingly.

-------------

PR: https://git.openjdk.org/jdk/pull/12062


More information about the hotspot-runtime-dev mailing list