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

8258382: Fix optimization-unstable code involving pointer overflow #1886

Closed
wants to merge 2 commits into from

Conversation

shqking
Copy link
Contributor

@shqking shqking commented Dec 24, 2020

Optimization-unstable code refers to code that is unexpectedly discarded
by compiler optimizations due to undefined behavior in the program.

We applied a static checker called STACK (prototype from SOSP'13 paper
[1]) to OpenJDK source code and found the following two sites of
potential unstable code involving pointer overflow.

Removing undefined behaviors would make the code stable.

[1] https://css.csail.mit.edu/stack/


Note that we tested locally Jtreg tests ( tier1 and jdk::tier3) were passed on Linux x86/aarch64 machines after apply this patch.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8258382: Fix optimization-unstable code involving pointer overflow

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/1886/head:pull/1886
$ git checkout pull/1886

Optimization-unstable code refers to code that is unexpectedly discarded
by compiler optimizations due to undefined behavior in the program.

We applied a static checker called STACK (prototype from SOSP'13 paper
[1]) to OpenJDK source code and found the following eight sites of
potential unstable code.

Removing undefined behaviors would make the code stable.

[1] https://css.csail.mit.edu/stack/
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 24, 2020

👋 Welcome back shqking! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Dec 24, 2020
@openjdk
Copy link

openjdk bot commented Dec 24, 2020

@shqking The following label will be automatically applied to this pull request:

  • hotspot

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.

@openjdk openjdk bot added the hotspot label Dec 24, 2020
@mlbridge
Copy link

mlbridge bot commented Dec 24, 2020

Webrevs

@kimbarrett
Copy link

kimbarrett commented Dec 24, 2020

I think there are somewhere between two and four distinct issues here
that should be dealt with in separate bugs and PRs (the number depends
on how the compiler folks might like things done). Their only relation
is that all were detected by the STACK tool. But they are in very
different parts of the code and probably ought to be reviewed by folks
from different teams.

src/hotspot/share/gc/parallel/psPromotionLAB.hpp Outdated Show resolved Hide resolved
src/hotspot/share/gc/parallel/psPromotionLAB.hpp Outdated Show resolved Hide resolved
src/hotspot/share/gc/parallel/psPromotionLAB.inline.hpp Outdated Show resolved Hide resolved
@shqking shqking changed the title 8258382: Fix optimization-unstable code 8258382: Fix optimization-unstable code involving pointer overflow Dec 25, 2020
@shqking
Copy link
Contributor Author

shqking commented Dec 25, 2020

I think there are somewhere between two and four distinct issues here
that should be dealt with in separate bugs and PRs (the number depends
on how the compiler folks might like things done). Their only relation
is that all were detected by the STACK tool. But they are in very
different parts of the code and probably ought to be reviewed by folks
from different teams.

Thanks for your suggestion.
I will put the other 6 issues involving signed integer overflow into another PR (https://bugs.openjdk.java.net/browse/JDK-8258946), and continue to use this PR to fix the pointer overflow checks.

Move the patch involving singed integer overflow into another PR.
In this patch we only fix optimization-unstable code involving pointer
overflow.

Update the patch based on feedback from upstream.
1) Remove unnecessary comment.
2) Remove unnecessary check between end() and top()
3) Use pointer_delta() to compute the offset between two addresses.

Change-Id: Icade8e1a4b684081036c85fd2a2b65b5c3b27f54
CustomizedGitHooks: yes
@openjdk openjdk bot added hotspot-gc and removed hotspot labels Dec 25, 2020
@openjdk
Copy link

openjdk bot commented Jan 1, 2021

@shqking 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:

8258382: Fix optimization-unstable code involving pointer overflow

Reviewed-by: kbarrett

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 15 new commits pushed to the master branch:

  • f5ee356: 8179503: Java should support GET OCSP calls
  • 8435f0d: 8258525: Some existing tests should use /nodynamiccopyright/ instead of the standard header
  • 07c93fa: Merge
  • 881bceb: 8258662: JDK 17ea: Crash compiling instanceof check involving sealed interface
  • fb607f1: 8245922: [macos] Taskbar.Feature.ICON_BADGE_NUMBER no longer supported on MacOS
  • 3f67afd: 8251377: [macos11] JTabbedPane selected tab text is barely legible
  • e2aa724: 8258941: Test specify the Classpath exception in the header
  • 779ee11: 8257147: [TESTBUG] Set a larger default loop count for the VectorAPI jtreg tests
  • 97c99b5: 8216400: improve handling of IOExceptions in JavaCompiler.close()
  • b575dd8: 8258914: javax/net/ssl/DTLS/RespondToRetransmit.java timed out
  • ... and 5 more: https://git.openjdk.java.net/jdk/compare/127582f81e7dbe9b72e38efb074aae48afb10b5b...master

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 (@kimbarrett) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@kimbarrett
Copy link

kimbarrett commented Jan 1, 2021

Thanks for splitting up the changes. The GC changes look good.

@openjdk openjdk bot added the ready label Jan 1, 2021
@shqking
Copy link
Contributor Author

shqking commented Jan 1, 2021

@kimbarrett thanks for your review.
/integrate

@openjdk openjdk bot added the sponsor label Jan 1, 2021
@openjdk
Copy link

openjdk bot commented Jan 1, 2021

@shqking
Your change (at version 4fc7949) is now ready to be sponsored by a Committer.

@nsjian
Copy link

nsjian commented Jan 4, 2021

/sponsor

@openjdk openjdk bot closed this Jan 4, 2021
@openjdk openjdk bot added integrated and removed sponsor ready rfr labels Jan 4, 2021
@openjdk
Copy link

openjdk bot commented Jan 4, 2021

@nsjian @shqking Since your change was applied there have been 17 commits pushed to the master branch:

  • 526c000: 8255729: com.sun.tools.javac.processing.JavacFiler.FilerOutputStream is inefficient
  • 497efef: 8225116: Test OwnedWindowsLeak.java intermittently fails
  • f5ee356: 8179503: Java should support GET OCSP calls
  • 8435f0d: 8258525: Some existing tests should use /nodynamiccopyright/ instead of the standard header
  • 07c93fa: Merge
  • 881bceb: 8258662: JDK 17ea: Crash compiling instanceof check involving sealed interface
  • fb607f1: 8245922: [macos] Taskbar.Feature.ICON_BADGE_NUMBER no longer supported on MacOS
  • 3f67afd: 8251377: [macos11] JTabbedPane selected tab text is barely legible
  • e2aa724: 8258941: Test specify the Classpath exception in the header
  • 779ee11: 8257147: [TESTBUG] Set a larger default loop count for the VectorAPI jtreg tests
  • ... and 7 more: https://git.openjdk.java.net/jdk/compare/127582f81e7dbe9b72e38efb074aae48afb10b5b...master

Your commit was automatically rebased without conflicts.

Pushed as commit f351e15.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kimbarrett
Copy link

kimbarrett commented Jan 4, 2021

This change should not have been pushed with only one review. HotSpot changes normally require two reviews.
https://wiki.openjdk.java.net/display/HotSpot/Pushing+a+HotSpot+change

I know the skara bots said it was ready to go. They haven't yet been taught about such project-specific tailorings of the base process. (The information in that page has supposedly been superseded by the new Developers' Guide (https://openjdk.java.net/guide/index.html), but the HotSpot reviewer requirements seem to have not made the transition. I'll bring that up with the dev-guide folks.)

@nsjian
Copy link

nsjian commented Jan 4, 2021

This change should not have been pushed with only one review. HotSpot changes normally require two reviews.
https://wiki.openjdk.java.net/display/HotSpot/Pushing+a+HotSpot+change

I know the skara bots said it was ready to go. They haven't yet been taught about such project-specific tailorings of the base process. (The information in that page has supposedly been superseded by the new Developers' Guide (https://openjdk.java.net/guide/index.html), but the HotSpot reviewer requirements seem to have not made the transition. I'll bring that up with the dev-guide folks.)

Thanks for the reminder! Sorry, I (mistakenly) thought that this is trivial change. I've also reviewed the patch internally and should have marked it reviewed by me before sponsoring.

@shqking shqking deleted the stack-ub branch Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-gc integrated
3 participants