-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8351660: C2: SIGFPE in unsigned_mod_value #24410
Conversation
👋 Welcome back sarannat! A progress list of the required criteria for merging this PR into |
@sarannat 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 422 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@eme64, @chhagedorn, @dafedafe) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
Thanks for the fix @sarannat! Do you think we could add the failing test as regression test (maybe in the already available Mod tests, without creating a new test file)? |
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.
@sarannat Good work :)
test/hotspot/jtreg/compiler/integerArithmetic/TestUnsignedModByZero.java
Outdated
Show resolved
Hide resolved
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.
Looks good!
src/hotspot/share/opto/divnode.cpp
Outdated
@@ -1319,6 +1319,11 @@ static const Type* unsigned_mod_value(PhaseGVN* phase, const Node* mod) { | |||
return TypeClass::ZERO; | |||
} | |||
|
|||
// Mod by zero? Throw exception at runtime! |
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.
// Mod by zero? Throw exception at runtime! | |
// Mod by zero? Throw an exception at runtime! |
} | ||
|
||
public static void main(String[] args) { | ||
for (int i =0; i < 10_000; i++) { |
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.
for (int i =0; i < 10_000; i++) { | |
for (int i = 0; i < 10_000; i++) { |
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.
Looks good to me otherwise.
/* | ||
* @test | ||
* @bug 8351660 | ||
* @summary Test that modulo by zero throws exception at runtime in case of unsigned values. |
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.
* @summary Test that modulo by zero throws exception at runtime in case of unsigned values. | |
* @summary Test that modulo by zero throws an exception at runtime in case of unsigned values. |
/contributor add @eme64 |
Thank you for the reviews. |
@sarannat |
/integrate |
/sponsor |
Going to push as commit 04e2a06.
Your commit was automatically rebased without conflicts. |
Description :: The test program performs a
Long.remainderUnsigned
which triggers the call to the functionunsigned_mod_value
. At the end ofunsigned_mod_value
the expression,return TypeClass::make(static_cast<Signed>(dividend % divisor))
, is computed which leads to a SIGFPE as the divisor in the test program is zero. The same behaviour was observed when theLong.remainderUnsigned
was replaced withInteger.remainderUnsigned
in the test program.Solution :: The fix for JDK-8345766 emitted specific ModF/ModD nodes, which is optimized and converted to runtime calls after optimizations. This was done during parsing prior to JDK-8345766. In the scenario where there was unsigned modulo operation as in this test, there was no check for modulo by zero that could trigger an exception during runtime. The below fix proposes a check for modulo by zero and throws exception at runtime.
A Jtreg test has been added as part of this fix. This test case is based on the original test that resulted in the bug. @eme64 is the contributor of the original test. Thank you @eme64.
Progress
Issue
Reviewers
Contributors
<[email protected]>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24410/head:pull/24410
$ git checkout pull/24410
Update a local copy of the PR:
$ git checkout pull/24410
$ git pull https://git.openjdk.org/jdk.git pull/24410/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24410
View PR using the GUI difftool:
$ git pr show -t 24410
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24410.diff
Using Webrev
Link to Webrev Comment