Skip to content

8382170: Assert in AnyObj::operator delete due to race condition in in_aot_cache()#30726

Open
iklam wants to merge 5 commits intoopenjdk:masterfrom
iklam:8382170-assert-in-anyobj-operator-delete-due-to-race-cond
Open

8382170: Assert in AnyObj::operator delete due to race condition in in_aot_cache()#30726
iklam wants to merge 5 commits intoopenjdk:masterfrom
iklam:8382170-assert-in-anyobj-operator-delete-due-to-race-cond

Conversation

@iklam
Copy link
Copy Markdown
Member

@iklam iklam commented Apr 14, 2026

The range _aot_metaspace_base ... _aot_metaspace_top is initialized in the main JVM thread during early bootstrap. In almost all cases when this range is consulted, the main thread has already published these two variables to all threads.

However, since JDK-8374549, we could read this range during GrowableArray size adjustment or destruction, which can legally happen in an ArchiveWorkerThread before the range is properly initialized and published. The reader could get inconsistent values from these two variables and assert.

The fix is to require the GrowableArray use cases (in GrowableArrayCHeapAllocator::deallocate() and AnyObj::in_aot_cache()) to explicitly check for _aot_metaspace_range_initialized with AtomicAccess::release_store/load_acquire.

I also an assert to make sure in all other cases, MetaspaceObj::is_pointer_in_aot_cache() is called only after the range is initialized. This should catch similar bugs in the future.

Performance:

For performance reasons, I do not use AtomicAccess to load the range itself. In the product build, AtomicAccess::load_acquire is called only in GrowableArrayCHeapAllocator::deallocate(), which happens very infrequently.



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-8382170: Assert in AnyObj::operator delete due to race condition in in_aot_cache() (Bug - P3)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30726

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Apr 14, 2026

👋 Welcome back iklam! 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 14, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Apr 14, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 14, 2026

@iklam 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.

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

mlbridge bot commented Apr 15, 2026

Webrevs

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

Labels

hotspot hotspot-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant