RFR: 8349787: java/lang/Thread/virtual/ThreadPollOnYield.java#default passes unexpectedly without libVThreadPinner.so [v3]

Alan Bateman alanb at openjdk.org
Wed Feb 12 08:25:11 UTC 2025


On Wed, 12 Feb 2025 07:43:50 GMT, SendaoYan <syan at openjdk.org> wrote:

>> Hi all,
>> 
>> Test test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java run passed unexpected without native library or with the incorrect native library path. The test command with incorrect native library path shows below. We will seen this tests run passed unexpected before this PR, because the first virtual thread do not run normally without the dependent shared library libVThreadPinner.so, and there is no assert when the first virtual thread run abnormal.
>> 
>> 
>> mkdir -p empty-directory ; jtreg -v:fail,error -w tmp -nr -jdk:build/linux-x86_64-server-release/images/jdk -nativepath:empty-directory test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java#default
>> 
>> 
>> This PR add a latch variable will make sure the first virtual thread run once at least. After this PR run the same test command which with incorrect native library path, and we will seen this pass run timed out as expected.
>> 
>> Change has been verified locally, test-fix only, no risk.
>
> SendaoYan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Rename latch to started, and do the countDown before the while loop

test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java line 51:

> 49: 
> 50: class ThreadPollOnYield {
> 51:     private static CountDownLatch started = new CountDownLatch(1);

Can you make this final?

test/jdk/java/lang/Thread/virtual/ThreadPollOnYield.java line 65:

> 63:             VThreadPinner.runPinned(() -> foo(done));
> 64:         });
> 65:         started.await();

I think this is okay. If the test is run directly with jtreg without libVThreadPinner.so then the virtual thread will throw and the main thread will wait indefinitely here, and the test will timeout.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23576#discussion_r1952180355
PR Review Comment: https://git.openjdk.org/jdk/pull/23576#discussion_r1952181937


More information about the core-libs-dev mailing list