RFR: 8364503: gc/g1/TestCodeCacheUnloadDuringConcCycle.java fails because of race printing to stdout

Albert Mingkun Yang ayang at openjdk.org
Fri Aug 1 13:46:59 UTC 2025


On Fri, 1 Aug 2025 10:31:53 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

> Hi all,
> 
>   please review this change to the `gc/g1/TestCodeCacheUnloadDuringConcCycle.java` test - previously, the GC that we were waiting for in the test could occur between releasing whitebox control and the marker we use to distinguish before/after test setup.
> 
> The change makes sure the marker is printed before releasing Whitebox control. So the concurrent start gc we look for can not happen before the marker printing.
> 
> Testing: passes 5000 runs of that benchmark
> 
> Thanks,
>   Thomas

test/hotspot/jtreg/gc/g1/TestCodeCacheUnloadDuringConcCycle.java line 165:

> 163:             // can start.
> 164:             System.out.println(TestCodeCacheUnloadDuringConcCycle.AFTER_FIRST_CYCLE_MARKER);
> 165:             System.out.flush();

I thought println already flushes the stdout. Why is explicit flush needed?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26592#discussion_r2248032389


More information about the hotspot-gc-dev mailing list