RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v2]
mcimadamore at openjdk.java.net
Wed Apr 28 18:21:54 UTC 2021
On Wed, 28 Apr 2021 18:07:32 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>> Address first batch of review comments
> src/java.base/share/classes/jdk/internal/module/IllegalNativeAccessChecker.java line 78:
>> 76: int index = 0;
>> 77: // the system property is removed after decoding
>> 78: String value = getAndRemoveProperty(prefix + index);
> I am not sure what is going on with the removal of the properties, but if I'm not mistaken this is racy: from the implementation of the checker() method above, it looks as if two different threads could trigger a call to the decode() function concurrently, which can result in a random partitioning of the properties against the two checkers being instantiated, with one of them being eventually set as the system-wide checker.
I think the method is called during module bootstrap - I don't think there is a race in practice. This method is also called in other parts of ModuleBootstrap. The code you allude to is called during initialization of the IllegalNativeAccessChecker singleton, which should happen only once, and only from one thread.
More information about the core-libs-dev