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

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

                Created:
                Updated:
                Resolved: