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

Native linker allows MemoryLayout consisting of only PaddingLayout

XMLWordPrintable

    • b26
    • generic
    • generic
    • Verified

      A DESCRIPTION OF THE PROBLEM :
      This code executes normally, although it shouldn't:

      Linker linker = Linker.nativeLinker();
      var padding = MemoryLayout.paddingLayout(1024).withByteAlignment(1024);
      var sequence = MemoryLayout.sequenceLayout(4, padding);
      var struct = MemoryLayout.structLayout(sequence);
      var fd = FunctionDescriptor.of(struct, struct);
      linker.downcallHandle(fd);

      I think that's the problem here:
      https://github.com/openjdk/jdk/blob/a8f143c6abe7669c232cabda3a4e8df726de036e/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java#L216
      Because there are no additional checks on what is inside the SequenceLayout.

      I highly recommend checking all the linker code related to SequenceLayout, because it seems for example for aarch64 the homogenous FP aggregate is incorrectly defined if ValueLayout are inside SequenceLayout



      FREQUENCY : always


            pminborg Per-Ake Minborg
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: