RFR: 8358680: AOT cache creation fails: no strings should have been added

David Holmes dholmes at openjdk.org
Wed Jun 18 05:06:28 UTC 2025


On Tue, 17 Jun 2025 15:54:25 GMT, Coleen Phillimore <coleenp 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.
>
> src/hotspot/share/compiler/compileTask.cpp line 93:
> 
>> 91: void CompileTask::wait_for_no_active_tasks() {
>> 92:   MonitorLocker locker(CompileTaskAlloc_lock);
>> 93:   while (_active_tasks > 0) {
> 
> Doesn't this have to have an Atomic::load() to make it re-read in the loop? Even though it's after we reacquire the lock.

Not if `_active_tasks` is only written whilst the same lock is held.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25816#discussion_r2153645613


More information about the hotspot-dev mailing list