-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8283337: Posix signal handler modification warning triggering incorrectly #7858
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
Conversation
👋 Welcome back kevinw! A progress list of the required criteria for merging this PR into |
@kevinjwalls The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Hi Kevin, Given:
I don't see how we can get the bogus warning ?? |
Ah sorry - wrong code. The warning comes from |
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 Also I note that if
and also check |
Trying to recall the details of Xin's JDK-8279124 to wrap my head around this one... The original problem was that we install the SIGQUIT handler when initializing the JDK as part of The solution was to install a first stop-gap signal handler for SIGQUIT at the very start of VM initialization, together with all other signals. That one just ignored SIGQUIT. Then we replace later that handler with the real one. The problem then was that signal change recognition was established for the first handler, and triggers warnings after the first handler is replaced by the second one. But both handlers are legit, so the warning was bogus. Xin solved this by disabling handler change recognition for SIGQUIT. He did not include Have I gotten this right, or have I forgotten something? -- For a workaround the proposed change is fine. It gets rid of the always present warning in hs-err files, at the cost of hiding it also when it would be useful. But that is okay, a warning that is always present gets quickly ignored. One code improvement would be to remove A better solution may be to save the second SIGQUIT handler too and reestablish the checks for SIGQUIT. Since we want to know if a third-party app changes SIGQUIT, and Xcheck:jni to tell us if that happens. A possible scenario, Customer complains about "vanishing VMs", but some third party lib just reset SIGQUIT and VM dies as soon as a Thread dump is triggered. Running with -Xcheck:jni would be the first thing I try, but right now it would not help. Cheers, Thomas |
Thanks both -- Yes Thomas your memory is fine I think the summary is good. 8-) Not sure about removing do_check_signal_periodically ? It still checks the others handlers, even if vm_handlers.get(SIGBREAK) returns null. Ideally yes we would save the second SIGQUIT handler - I think the problem there is that it is set later by os::signal() which doesn't have a way to distinguish itself from any other native code setting a handler. It is the kind of signal action setting code which this saved handler mechanism is trying to notice (and it does notice it!) I think that os::signal() call to set the BREAK/QUIT handler was never being saved in vm_handlers, so we haven't actually been checking for changed handlers there. David's comment about reversing these lines 838 os::print_signal_handlers(tty, buf, O_BUFLEN); ..and checking do_check_signal_periodically[sig] in print_signal_handlers: Yes, I almost added checking do_check_signal_periodically[sig] in print_signal_handlers. There is some duplication of warnings, but they are different: if periodic check finds a mismatch, it warns (shows which handler has changed): Warning: SIGQUIT handler modified! ...then calls print_handlers which warns more specifically (what the handler is, and what we expected): *** Handler was modified! Actually, the periodic check can get really verbose: it prints all handlers, for each individual handler it sees changed. os::run_periodic_checks() ...each of which might make this call: ...so thankfully we don't see this very often. I get it now that line 838 should probably be printing ONE handler: This is a removal of a regression so don't want to feature-creep too much, but I'll try that change. |
I was under assumption that do_check_signal_periodically[] = true and vm_handlers.get() != NULL mean the same. But I see now there are subtle differences: when Xcheck:jni encounters a mismatch, it prints out a warning, and then disables the check by setting do_check_signal_periodically[] = false. But it leaves vm_handlers intentionally unchanged, so in the hs-err file we still get noticed about the changed handler. That way we have a warning on stdout, and one in the hs-err file. So please ignore my proposal about removing do_check_signal_periodically.
I wondered about that too. The question is whether its valid to repurpose hotspot signals when done via the official java API. And while I think about this, probably not. You are right, a blanket "ok" for os::signal() would be wrong. We could just try and handle SIGQUIT differently. But everything I can come up quickly is hacky. E.g. treat the first modification of SIGQUIT via java special. But oh god thats ugly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is reasonable.
@kevinjwalls This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 41 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Yes, it looks OK if check_signal_handler calls: PosixSignals::print_signal_handler(tty, sig, buf, O_BUFLEN); It would give output like: $ build/linux-x86_64-server-release/images/jdk/bin/java -Xcheck:jni ...testapp... This shows the duplication, and it's not bad, even desirable as it means the message starts with "Warning:" which tries to separate it from other output. I'd like to integrate this PR as is, to fix the regression in the warning quickly, unless any other thoughts. Can separately do a change to print only the handler that has changed as that looks like a mistake. |
I'm still fine with this change. David is on vacation I believe. Lets wait till next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think that we are checking the wrong condition in print_signal_handler. This is okay as a quick fix but there needs to be a follow up RFE to clean this up.
Thanks,
David
/integrate |
Going to push as commit 45d4d7d.
Your commit was automatically rebased without conflicts. |
@kevinjwalls Pushed as commit 45d4d7d. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
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.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7858/head:pull/7858
$ git checkout pull/7858
Update a local copy of the PR:
$ git checkout pull/7858
$ git pull https://git.openjdk.java.net/jdk pull/7858/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 7858
View PR using the GUI difftool:
$ git pr show -t 7858
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7858.diff