RFR: 8358680: AOT cache creation fails: no strings should have been added
Aleksey Shipilev
shade at openjdk.org
Tue Jun 17 15:52:29 UTC 2025
On Mon, 16 Jun 2025 03:30:40 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> Background: when writing the string table in the AOT cache, we do this:
>
> 1. Find out the number of strings in the interned string table
> 2. Allocate Java object arrays that are large enough to store these strings. These arrays are used by `StringTable::lookup_shared()` in the production run.
> 3. Enter safepoint
> 4. Copy the strings into the arrays
>
> This bug happened because:
>
> - Step 1 is not thread safe, so it may be reading a stale version of `_items_count`
> - JIT compiler threads may create more interned strings after step 1
>
> This PR attempts to fix both issues.
Actually, I need https://github.com/openjdk/jdk/pull/25409 in mainline first :)
Would be nice to avoid divergence between JDK 25, JDK 26 and Leyden/premain.
Anyhow, I now think this fix in incomplete. In premain, we use this `wait_for_no_active_tasks`, because we _know_ all the compiler tasks were queued, and we just need to run them down. But here, we still have a race: compiler threads may finish current batch of compilations, `wait_for_no_active_tasks` would return, and _then_ we can start compiling again.
I think we need to figure our when we dump the shared table. Maybe even shutdown the compiler right before going into CDS dump? See how `CompileBroker::set_should_block` and `VM_Exit::wait_for_threads_in_native_to_block` do it. It would still be pretty awkward for a fix.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25816#issuecomment-2977450172
PR Comment: https://git.openjdk.org/jdk/pull/25816#issuecomment-2980907758
More information about the hotspot-dev
mailing list