RFR: 8334215: serviceability/dcmd/thread/PrintMountedVirtualThread.java failing with JTREG_TEST_THREAD_FACTORY=Virtual [v3]

Inigo Mediavilla Saiz duke at openjdk.org
Tue Jun 18 11:41:37 UTC 2024


On Tue, 18 Jun 2024 09:31:41 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> @AlanBateman explained to me why that is possible in https://github.com/openjdk/jdk/pull/19482#issuecomment-2166116062 and https://github.com/openjdk/jdk/pull/19482#issuecomment-2167374446. 
>> 
>> Alan can correct me if I'm wrong, but I think that the dummy thread trying to unpark the main (virtual) thread needs to run as the carrier to avoid nested parking. See: https://github.com/openjdk/jdk/blob/412e306d81209c05f55aee7663f7abb80286e361/src/java.base/share/classes/java/lang/VirtualThread.java#L707
>
> So IIUC you've changed the test to try to avoid the problem that was causing the test to fail, as well as changing the code so the test would not fail. But now we won't/may-not actually test that. ?? I guess I want to see that the original failing test now passes with the fix.

The fix in the threads.cpp code prevents the `Mounted Thread` statement to be printed when the command is incapable of actually printing the Vthread stack because the Vthread is running in the context of the carrier. A vthread running in the context of the carrier can happen when the vthread is undergoing a transition, for example when the vthread  unparks another virtual thread.

Even with that fix, the original test was invalid because it expected to always see the mounted thread in the ouptut, but waking up the main virtual thread after `started.await()` required that the dummy vthread had to unpark the main vthread, what requires a that dummy unparks main and has to transition to carrier. After the fixed done in `threads.cpp` this would result in the mounted thread not showing up in the output in some cases.

To sum up, we needed both changes but the `threads.cpp` change did not make the original test pass.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19744#discussion_r1644315802


More information about the hotspot-runtime-dev mailing list