RFR: 8352088: Call of com.sun.jdi.ThreadReference.threadGroups() can lock up target VM

Alan Bateman alanb at openjdk.org
Wed Mar 26 09:34:19 UTC 2025


On Wed, 26 Mar 2025 01:57:41 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Calling ThreadGroupReference.groups() from an event handler can cause a deadlock. Details in first comment. Tested with :jdk_lang on all supported platforms and tier1, tier2, tier3, and tier5 svc testing.
>
> src/java.base/share/classes/java/lang/ThreadGroup.java line 664:
> 
>> 662:     private ThreadGroup[] subgroupsAsArray() {
>> 663:         List<ThreadGroup> groups = synchronizedSubgroups();
>> 664:         return groups.toArray(new ThreadGroup[groups.size()]);
> 
> Hello Chris, would a comment on this line be necessary to prevent future (IDE encouraged [1]) refactoring of this code back to `toArray(new ThreadGroup[0])`?
> 
> [1] 
> <img width="983" alt="toArray" src="https://github.com/user-attachments/assets/643e66b8-c18a-4a10-8961-2aa3b2869fcc" />

What would you think about using the simple code + loop from the JBS comment? That would remove any discussion about toArray and any concerns that it would load classes.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24236#discussion_r2013716726


More information about the core-libs-dev mailing list