RFR: 8338417: Explicitly pin a virtual thread before acquiring the JFR string pool monitor

Markus Grönlund mgronlun at openjdk.org
Thu Aug 15 09:48:57 UTC 2024


On Thu, 15 Aug 2024 04:11:47 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Greetings,
>> 
>> Explicitly pin a virtual thread before acquiring the JFR string pool monitor because migrating a carrier thread local event writer object onto another carrier thread is impossible.
>> 
>> During event commit, the thread is in a critical section because it has loaded a carrier thread local event writer object. For virtual threads, a contended monitor, such as a synchronized block, is a point where a thread could become unmounted.
>> 
>> A monitor guards the JFR string pool, but remounting a virtual thread onto another carrier is impossible because of the event writer.
>> 
>> Therefore, it's imperative to use explicit pin constructs to prevent unmounting at this location. 
>> 
>> Testing: jdk_jfr
>> 
>> Thanks
>> Markus
>
> src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java line 93:
> 
>> 91:     private static long storeString(String s) {
>> 92:         try {
>> 93:             pinVirtualThread();
> 
> The pin should be outside the try so that the finally can only happen if pinning was succesful.

Good point, thanks.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20588#discussion_r1718199292


More information about the core-libs-dev mailing list