RFR: 8283337: Posix signal handler modification warning triggering incorrectly
David Holmes
dholmes at openjdk.java.net
Fri Mar 18 04:28:26 UTC 2022
On Thu, 17 Mar 2022 19:23:10 GMT, Kevin Walls <kevinw at openjdk.org> wrote:
> PosixSignals::print_signal_handler() is incorrectly detecting a changed signal handler. The signal handler for SIGBREAK/SIGQUIT is now set in src/hotspot/os/posix/signals_posix.cpp with the bool parameter do_check set to false.
>
> set_signal_handler should only store a handler in vm_handlers when do_check is true.
>
> However I don't see a simple way of getting a valid warning for the SIGQUIT handler, if it is added later when os::initialize_jdk_signal_support() calls os::signal().
>
> If only signals added directly by src/hotspot/os/posix/signals_posix.cpp have the warning for a handler changing, then we never had a warning for SIGQUIT, so just this simple change is needed to remove the bogus warning.
Okay ... so the basic problem is two similar pieces of code use different guards for checking for a changed handler. The real checking code does check `do_check_signal_periodically[sig]`, while the printing code just checks whether `vm_handlers.get(sig) == NULL`. So one way to fix is to ensure the handler is NULL when not checking - which is the current fix. Alternatively, change `print_signal_handlers` so that it instead checks `do_check_signal_periodically[sig]` (and just asserts the handler is not NULL).
Also I note that if `check_signal_handler` finds a mismatch it will call `print_signal_handlers` which will issue the mismatch warning a second time. That can be fixed if we swap these two lines:
838 os::print_signal_handlers(tty, buf, O_BUFLEN);
839 do_check_signal_periodically[sig] = false;
and also check ` do_check_signal_periodically[sig]` in `print_signal_handlers`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7858
More information about the hotspot-runtime-dev
mailing list