[foreign-memaccess+abi] RFR: 8317514: Ensure MemorySegment is initialized before touching NativeMemorySegmentImpl [v2]

Jorn Vernee jvernee at openjdk.org
Mon Oct 9 19:16:01 UTC 2023


On Mon, 9 Oct 2023 18:34:21 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> test/jdk/java/foreign/TestDeadlock.java line 51:
>> 
>>> 49:         });
>>> 50: 
>>> 51:         Thread t2 = Thread.ofPlatform().start(() -> {
>> 
>> We do not seem to test:
>> * mapped segments
>> * symbol lookup segments
>> * linker-generated segments
>> 
>> Is that ok?
>
> I'll try to add a test for mapped segments as well (through FileChannel::map). Though, it might not be possible to reproduce an issue in a test. 
> 
> But, the other two do not touch NativeMemorySegmentImpl or MappedMemorySegmentImpl directly, so I'm not sure. Theoretically we can test all the API points (that create MemorySegments), but given the tricky timing (the current test has to carefully pre-initialize several classes to get there), I'm not sure it's useful to spend resources on running those tests.

I've added a similar test for FileChannel::map, but was not able to reproduce a deadlock. The log shows that the basic conditions are right, but I guess we just miss the timing:


[0.182s][info][class,init] 728 Initializing 'java/lang/foreign/MemorySegment' (0x0000021a82050320) by thread "Thread-2"
[0.183s][info][class,init] 729 Initializing 'jdk/internal/foreign/AbstractMemorySegmentImpl' (0x0000021a82050d28) by thread "Thread-2"
[0.183s][info][class,init] 730 Initializing 'jdk/internal/foreign/NativeMemorySegmentImpl' (0x0000021a82051598) by thread "Thread-2"
[0.183s][info][class,init] 731 Initializing 'jdk/internal/foreign/MappedMemorySegmentImpl' (0x0000021a82051e20) by thread "Thread-1"

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

PR Review Comment: https://git.openjdk.org/panama-foreign/pull/902#discussion_r1350711203


More information about the panama-dev mailing list