RFR: 8303916: ThreadLists.java inconsistent results

David Holmes dholmes at openjdk.org
Thu Jun 15 02:17:15 UTC 2023


On Wed, 14 Jun 2023 09:30:49 GMT, Kevin Walls <kevinw at openjdk.org> wrote:

> This test fails when additional threads are created, as it compares thread lists from different sources and sees a mismatch.
> 
> It needs to tolerate some threads with certain names appearing, e.g. JVMCI and ForkJoin threads.  If there are extra threads in the thread ID list from the ThreadMBean, remove them from the thread count before comparing.
> 
> When it fails, additionally print the ids and names of threads that it got from the MBean.
> 
> I found the test quite confusing, the naming of thread counts, arrays of threads, and arrays of thread stacktraces from different sources, so have renamed some things.

The test assumes that it can find a set of steady-state threads running that does not change, but that is not the case. I don't find this test particularly useful in what it attempts to do. It would make more sense to have a set of test threads that it looks for via each method, and which it can control termination of and thus check that they disappear. Adding an allow-list of dynamically appearing threads seems somewhat fragile, but I guess we've really only seen two problematic scenarios:
- Running with virtual threads
- Running with JVMCI
so the fix "works".

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

Marked as reviewed by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14465#pullrequestreview-1480552511


More information about the serviceability-dev mailing list