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

8336911: ZGC: Division by zero in heuristics after JDK-8332717 #21304

Closed
wants to merge 2 commits into from

Conversation

MBaesken
Copy link
Member

@MBaesken MBaesken commented Oct 2, 2024

When running with ubsan enabled binaries, the following issue is reported,
e.g. in test
compiler/uncommontrap/TestDeoptOOM_ZGenerational.jtr
also in gc/z/TestSmallHeap.jtr

jdk/src/hotspot/share/gc/z/zDirector.cpp:537:84: runtime error: division by zero
    #0 0x7f422495bd1f in calculate_young_to_old_worker_ratio src/hotspot/share/gc/z/zDirector.cpp:537
    #1 0x7f422495bd1f in select_worker_threads src/hotspot/share/gc/z/zDirector.cpp:694
    #2 0x7f42282a0d97 in select_worker_threads src/hotspot/share/gc/z/zDirector.cpp:689
    #3 0x7f42282a0d97 in initial_workers src/hotspot/share/gc/z/zDirector.cpp:784
    #4 0x7f42282a2485 in initial_workers src/hotspot/share/gc/z/zDirector.cpp:795
    #5 0x7f42282a2485 in start_minor_gc src/hotspot/share/gc/z/zDirector.cpp:797
    #6 0x7f42282a2485 in start_gc src/hotspot/share/gc/z/zDirector.cpp:826
    #7 0x7f42282a2485 in ZDirector::run_thread() src/hotspot/share/gc/z/zDirector.cpp:912
    #8 0x7f422840bdd8 in ZThread::run_service() src/hotspot/share/gc/z/zThread.cpp:29
    #9 0x7f4225ab6979 in ConcurrentGCThread::run() src/hotspot/share/gc/shared/concurrentGCThread.cpp:48
    #10 0x7f4227e1137a in Thread::call_run() src/hotspot/share/runtime/thread.cpp:225
    #11 0x7f42274619b1 in thread_native_entry src/hotspot/os/linux/os_linux.cpp:858
    #12 0x7f422c8d36e9 in start_thread (/lib64/libpthread.so.0+0xa6e9) (BuildId: 9a146bd267419cb6a8cf08d7c602953a0f2e12c5)
    #13 0x7f422c1dc58e in clone (/lib64/libc.so.6+0x11858e) (BuildId: f2d1cb1ef49f8c47d43a4053910ba6137673ccce)

The division by 0 leads to 'infinity' on most of our platforms. So instead of relying on this behavior, we can add a small check and set 'infinity' for divisor == 0.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8336911: ZGC: Division by zero in heuristics after JDK-8332717 (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21304/head:pull/21304
$ git checkout pull/21304

Update a local copy of the PR:
$ git checkout pull/21304
$ git pull https://git.openjdk.org/jdk.git pull/21304/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21304

View PR using the GUI difftool:
$ git pr show -t 21304

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21304.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 2, 2024

👋 Welcome back mbaesken! 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
Copy link

openjdk bot commented Oct 2, 2024

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

8336911: ZGC: Division by zero in heuristics after JDK-8332717

Reviewed-by: aboldtch, eosterlund

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

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8336911: ZGC: Division by zero in heuristics after JDK-8332717 8336911: ZGC: Division by zero in heuristics after JDK-8332717 Oct 2, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 2, 2024
@openjdk
Copy link

openjdk bot commented Oct 2, 2024

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

  • hotspot-gc

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.

@mlbridge
Copy link

mlbridge bot commented Oct 2, 2024

Webrevs

Copy link
Member

@xmas92 xmas92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think infinity is the solution here. There are more problems with the heuristics when no young collection has reclaimed any memory.

I added a comment about this in an earlier PR (JDK-8339648 / #20888) #20888 (comment).

I proposed a solution to this specific issue that makes more sense to me, and avoid the NaN issues here. But will have to talk it over.

Regardless I think we need to do an overhaul of this code to handle the extreme case of no GC having reclaimed any memory.

Also this must have been an issue before JDK-8332717 as well?

Copy link
Contributor

@fisk fisk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the end I'd like to sanitize the input data to all these calculations to have less zeros and hence divisions by zero. But we can do that as a separate cleanup. This change looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 16, 2024
@MBaesken
Copy link
Member Author

Thanks for the reviews !

/integrate

@openjdk
Copy link

openjdk bot commented Oct 16, 2024

Going to push as commit 1cc3223.
Since your change was applied there have been 208 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 16, 2024
@openjdk openjdk bot closed this Oct 16, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 16, 2024
@openjdk
Copy link

openjdk bot commented Oct 16, 2024

@MBaesken Pushed as commit 1cc3223.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-gc [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants