RFR: 8334394: Race condition in Class::protectionDomain

Weijun Wang weijun at openjdk.org
Mon Jun 17 15:14:14 UTC 2024


On Mon, 17 Jun 2024 15:08:26 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Make sure `pd` is always the same object when `getProtectionDomain0` is null.
>
> test/jdk/java/lang/Class/ProtectionDomainRace.java line 42:
> 
>> 40:                 try {
>> 41:                     Subject.doAs(null, ac);
>> 42:                 } catch (Throwable t) {
> 
> This can test for the racy NPE, but it cannot detect if there's distinct allPermDomain objects written by races. Should we add another check to defend against that?

Actually it can. This bug originally breaks the `assert` statement at https://github.com/openjdk/jdk/blob/5cea53d372744ddf1bedaae4667415e6525ef82f/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java#L1209.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19752#discussion_r1642973826


More information about the core-libs-dev mailing list