Skip to content

8381382: Shenandoah: assert(capacity > 0) failed: free regions must have allocation capacity#30615

Closed
pengxiaolong wants to merge 5 commits intoopenjdk:masterfrom
pengxiaolong:JDK-8381382
Closed

8381382: Shenandoah: assert(capacity > 0) failed: free regions must have allocation capacity#30615
pengxiaolong wants to merge 5 commits intoopenjdk:masterfrom
pengxiaolong:JDK-8381382

Conversation

@pengxiaolong
Copy link
Copy Markdown

@pengxiaolong pengxiaolong commented Apr 8, 2026


The improvement I made in ticket https://bugs.openjdk.org/browse/JDK-8345423 makes trash region be recycled by GC workers w/o holding heap lock, this may cause assert from mutator memory allocation path in which mutator calls ShenandoahFreeSet::assert_bounds() perform verifications, given GC workers recycle trashed region w/o heap lock, it is possible that one mutator can see inconsistent heap stats while a GC worker thread is recycling the same trashed region. It is not possible to happen for mem allocation except the verification, because before allocating inside a region, mutator always calls ShenandoahHeapRegion::try_recycle_under_lock() which ensure the region is ready for use, but ShenandoahFreeSet::assert_bounds scans all regions rather than the region mutator tries to allocate in.

I feel the assert used to rarely happen, because ShenandoahFreeSet::assert_bounds is called only when the region is retired due to insufficient memory, but this behavior was changed in recently commit which unifies the heap usage accounting, with it, mutator calls assert_bounds for every single allocation from heap, this make the assert to happen more often.

Test

  • 300 times of test/hotspot/jtreg/applications/jcstress/volatiles.java
  • hotspot_gc_shenandoah
  • GHA

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-8381382: Shenandoah: assert(capacity > 0) failed: free regions must have allocation capacity (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30615

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@pengxiaolong pengxiaolong changed the title 8381382: Shenandoah: assert(capacity > 0) failed: free regions must h… 8381382: Shenandoah: assert(capacity > 0) failed: free regions must have allocation capacity Apr 8, 2026
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Apr 8, 2026

👋 Welcome back xpeng! 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
Copy Markdown

openjdk bot commented Apr 8, 2026

@pengxiaolong This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot added hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Apr 8, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 8, 2026

@pengxiaolong The following labels will be automatically applied to this pull request:

  • hotspot-gc
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@pengxiaolong pengxiaolong marked this pull request as ready for review April 8, 2026 00:39
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 8, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Apr 8, 2026

Webrevs

Copy link
Copy Markdown
Contributor

@kdnilsen kdnilsen left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 9, 2026
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 13, 2026
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 13, 2026
@pengxiaolong pengxiaolong marked this pull request as draft April 13, 2026 22:51
@pengxiaolong
Copy link
Copy Markdown
Author

pengxiaolong commented Apr 13, 2026

Converting it back to draft, I am working and testing on lightweight solution instead of creating ShenandoahLock instance for each region(it works, but it is bit overkill, I have been running the stress test for over 3 days, not crash so far).

@pengxiaolong
Copy link
Copy Markdown
Author

Closing this one, we have lightweight solution to fix this.

#30723

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants