Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8347047

Cleanup action passed to MemorySegment::reinterpret keeps old segment alive

XMLWordPrintable

        AbstractMemorySegment::reinterpretInternal does this:

        Runnable action = cleanup != null ?
                        () -> cleanup.accept(SegmentFactories.makeNativeSegmentUnchecked(address(), newSize)) :
                        null;

        While in principle this code should completely decouple the cleanup action from the old segment, the accidental call to the instance method `address()` defeats that purpose. This results in a segment that can't be cleaned up, as described here:

        https://mail.openjdk.org/pipermail/panama-dev/2024-December/020870.html

              pminborg Per-Ake Minborg
              mcimadamore Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: