Skip to content
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

Fix signal handler registration in the JVM #2965

Merged
merged 1 commit into from
Sep 20, 2018

Conversation

babsingh
Copy link
Contributor

@babsingh babsingh commented Sep 20, 2018

omrsig.cpp::omrsig_primary_sigaction/omrsig_primary_signal doesn't
support registration with SIG_DFL/SIG_IGN/NULL as the signal handler.

  1. SIG_IGN is passed as the signal handler for SIGPIPE.
  2. NULL is passed as the new signal handler for SIGILL.

In the above cases, omrsig_primary_sigaction/omrsig_primary_signal
shouldn't be used for registering a signal handler.

Now onwards, only <signal.h>::sigaction/signal will used in the above
cases.

SIGPIPE needs to be ignored for the Java Attach API to work properly.

Fixes #2871

Signed-off-by: Babneet Singh sbabneet@ca.ibm.com

@pdbain-ibm
Copy link
Contributor

@pshipton would you kindly run an extended build so we can see it this fixes the attach API error handling failure?
@babsingh did you test it with the test case supplied with issue #2871?

Thank you.

@pshipton
Copy link
Member

Are there any other places/signals with a similar problem?

jenkins test extended zlinux jdk8

@pshipton
Copy link
Member

@babsingh
Copy link
Contributor Author

did you test it with the test case supplied with issue #2871?

yes, it passes.

OMRSIG_SIGACTION(SIGILL, NULL, &oldHandler);

yes, this place would also need to be fixed since omrsig_primary_sigaction would return error for NULL signal handler without setting the old handler. so, omrsig lib shouldn't be used in this scenario. i will update the PR.

@babsingh babsingh changed the title Fix signal handler registration for SIGPIPE Fix signal handler registration in the JVM Sep 20, 2018
@babsingh
Copy link
Contributor Author

@pshipton I have updated two other places where omrsig_primary_sigaction/omrsig_primary_signal shouldn't be used.

omrsig.cpp::omrsig_primary_sigaction/omrsig_primary_signal doesn't
support registration with SIG_DFL/SIG_IGN/NULL as the signal handler.

1) SIG_IGN is passed as the signal handler for SIGPIPE.
2) NULL is passed as the new signal handler for SIGILL.
 
In the above cases, omrsig_primary_sigaction/omrsig_primary_signal
shouldn't be used for registering a signal handler. 

Now onwards, only <signal.h>::sigaction/signal will used in the above
cases.

SIGPIPE needs to be ignored for the Java Attach API to work properly.

Fixes eclipse-openj9#2871

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
@pshipton
Copy link
Member

pshipton commented Sep 20, 2018

The port library code wasn't affected by #2631 as I understand it. Plus the code just seems wrong. I think we should leave this one for further investigation and a different PR.

@pshipton
Copy link
Member

Waiting for https://ci.eclipse.org/openj9/job/PullRequest-Extended-JDK8-linux_390-64_cmprssptrs-OpenJ9/72/ to complete and pass.

jenkins compile xlinux jdk8

@babsingh
Copy link
Contributor Author

babsingh commented Sep 20, 2018

Removed changes related to SIG_RI_INTERRUPT from this PR.

Opened #2967 to resolve the issue related to SIG_RI_INTERRUPT.

@babsingh
Copy link
Contributor Author

@pshipton https://ci.eclipse.org/openj9/job/PullRequest-Extended-JDK8-linux_390-64_cmprssptrs-OpenJ9/72/ has passed.

I have verified that org.openj9.test.attachAPI.TestAttachErrorHandling:test_startupShutdownRobustness is passing: https://ci.eclipse.org/openj9/job/PullRequest-Extended-JDK8-linux_390-64_cmprssptrs-OpenJ9/72/consoleFull.

@DanHeidinga
Copy link
Member

I think we want to revisit this and the original PR #2631

The extra rules on the use of signal vs omr_* apis increases the likelihood of future bugs when these rules are missed by developers & reviewers.

@babsingh
Copy link
Contributor Author

we want to revisit this

Agreed, we should revisit this. right approach: omrsig_primary_signal/omrsig_primary_sigaction should behave similar to signal/sigaction. omrsig_primary_signal/omrsig_primary_sigaction should be updated to handle SIG_IGN/SIG_DFL/NULL cases similar to signal/sigaction. this way omrsig_primary_signal/omrsig_primary_sigaction and signal/sigaction can be used interchangeably. @DanHeidinga do you agree? if agreed, i will open an OMR issue.

@pshipton
Copy link
Member

omrsig_primary_signal/omrsig_primary_sigaction should behave similar to signal/sigaction

I'm not sure this actually works. There is a difference between user code calling sigaction, and the VM calling sigaction. If the VM has registered a signal we don't want user code to then set it to ignore or default.

@DanHeidinga
Copy link
Member

@babsingh Can you open an issue and outline the changes that have been made so far, why they were made, and what you think the right path forward is?

Let's have the discussion in a top-level issue rather than in the comments on an already merged PR. Too easy to lose this discussion :)

@babsingh babsingh deleted the fix_socket_close_write branch August 17, 2020 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants