RFR: 8320886: Unsafe_SetMemory0 is not guarded

Jorn Vernee jvernee at openjdk.org
Wed Nov 29 08:58:06 UTC 2023


On Tue, 28 Nov 2023 18:58:30 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> See JBS issue.
>> 
>> Guard the memory access done in Unsafe_SetMemory0 to prevent a SIGBUS error from crashing the VM when a truncated memory mapped file is accessed.
>> 
>> Testing: local `InternalErrorTest`, Tier 1-5 (ongoing)
>
> I'm looking into the crash on mac

> @JornVernee is there some "new" usage of this method such that it needs guarding?

This function is now exposed (indirectly) through the new `MemorySegment::fill` API. There are some rare other uses of `Unsafe.setMemory` in the JDK, and some seem to be operating on user-supplied buffers, so this issue might have existed for longer already. For instance in `GaloisCounterMode`, but it's hard to tell for me where the ByteBuffer that this is operating on comes from.

I went through the original review thread starting here: https://mail.openjdk.org/pipermail/hotspot-dev/2019-February/037058.html but I don't see a reference to `setMemory`.

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

PR Comment: https://git.openjdk.org/jdk/pull/16848#issuecomment-1831476713


More information about the hotspot-dev mailing list