[lworld] RFR: 8362252: [lworld] Possible synchronization issue in jdk/internal/jimage/ImageReader.java
David Beaumont
duke at openjdk.org
Thu Jan 22 10:55:35 UTC 2026
On Thu, 18 Dec 2025 13:54:26 GMT, David Beaumont <duke at openjdk.org> wrote:
>> Tidying up syncrhonization around shared image.
>
> src/java.base/share/classes/jdk/internal/jimage/ImageReader.java line 444:
>
>> 442: nodes.clear();
>> 443: }
>> 444: super.close();
>
> I will double check if moving this outside the synchronization of OPEN_FILES is an issue.
> The underlying BasicImageReader using a file channel, which is close (with locking) in this close() method.
> The vague worry I have is that now the outter OPEN_FILES lock isn't held, we can get a race where the same file has a file channel being closed as a new one is being opened, and I'm not 100% sure I know if that's safe.
> Moving this back into the OPEN_FILES lock is possible, but leaves this code doing more work with the locks held, which I'm inclined to avoid if possible.
Roger, I'd still want a confirmation of the safety around channel opening/closing on the same underlying file.
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1828#discussion_r2716374433
More information about the valhalla-dev
mailing list