Integrated: 8325202: gc/g1/TestMarkStackOverflow.java intermittently crash: G1CMMarkStack::ChunkAllocator::allocate_new_chunk
Ivan Walulya
iwalulya at openjdk.org
Fri Feb 23 10:50:59 UTC 2024
On Mon, 19 Feb 2024 11:04:16 GMT, Ivan Walulya <iwalulya at openjdk.org> wrote:
> Please review this bug fix to guarantee that expanding the G1CMMarkStack considers the expected capacity for the thread triggering the expansion instead of expanding based on current capacity.
>
> Failure Mode:
> Assume current stack capacity is 1:
>
> 1: Thread 1: Obtains `cur_idx` as 1 and notices that the associated bucket is not allocated, indicating insufficient capacity. It then attempts to double the capacity to 2.
> 2: Thread 2: Obtains `cur_idx` as 2 and finds that the bucket associated with index 2 is also not allocated. Consequently, Thread 2 also tries to expand the stack.
> 3: Due to a delay in Thread 1's execution, Thread 2 acquires the lock first and initiates the expansion by calling the `expand()` function. This function doubles the capacity from 1 to 2.
> 4: However, upon returning from the expansion, the bucket associated with `cur_idx` 2 remains unallocated. Consequently, when Thread 2 tries to access this bucket, it crashes.
>
> The problem is that the `expand()` function is called without considering the specific thread context that necessitated the expansion. Instead, it expands the capacity based on the current size of the stack, leading to races when multiple threads concurrently attempt to expand the stack's capacity.
>
> Testing: - Tier 1 -3
> - 2M test iterations (bug is reproducible ~1/100k test iterations)
This pull request has now been integrated.
Changeset: 11fdca06
Author: Ivan Walulya <iwalulya at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/11fdca06345542b8d5e54feb1d16f17c2bcb1a82
Stats: 22 lines in 2 files changed: 12 ins; 1 del; 9 mod
8325202: gc/g1/TestMarkStackOverflow.java intermittently crash: G1CMMarkStack::ChunkAllocator::allocate_new_chunk
Reviewed-by: tschatzl, ayang
-------------
PR: https://git.openjdk.org/jdk/pull/17912
More information about the hotspot-gc-dev
mailing list