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

vaList.skip() has an inconsistent behaviour in different systems

XMLWordPrintable

      MacOS/Linux:
      jshell> VaList vaList = VaList.make(builder -> builder.addVarg(ValueLayout.JAVA_INT, 77), SegmentScope.global());
      vaList ==> SysVVaList{gp_offset=0, fp_offset=48, overflow_ar ... 553167139696 limit: 176 }}

      jshell> vaList.skip(ValueLayout.JAVA_DOUBLE)
      | Exception java.util.NoSuchElementException: No such element: d64
      | at SharedUtils.newVaListNSEE (SharedUtils.java:326)
      | at SysVVaList.checkRegSaveAreaElement (SysVVaList.java:295)
      | at SysVVaList.skip (SysVVaList.java:318)
      | at (#5:1)
      jshell> vaList.nextVarg(ValueLayout.JAVA_INT)
      $6 ==> 77

      Windows has other output:
      jshell> import java.lang.foreign.*
      jshell> VaList vaList = VaList.make(builder->builder.addVarg(ValueLayout.JAVA_INT, 77), SegmentScope.global());
      vaList ==> jdk.internal.foreign.abi.x64.windows.WinVaList@3d99d22e
      jshell> vaList.skip(ValueLayout.JAVA_DOUBLE)

      jshell> vaList.nextVarg(ValueLayout.JAVA_INT)
      | Exception java.util.NoSuchElementException: No such element: i32
      | at SharedUtils.newVaListNSEE (SharedUtils.java:326)
      | at WinVaList.checkElement (WinVaList.java:137)
      | at WinVaList.read (WinVaList.java:112)
      | at WinVaList.read (WinVaList.java:106)
      | at WinVaList.nextVarg (WinVaList.java:81)
      | at (#4:1)

      Expected behaviour should be as the same as shown in Linux. The issue was revealed while testing the assertion:
      VaList.skip(MemoryLayout[])::Throws: NoSuchElementException - if an out-of-bounds read is detected.

            jvernee Jorn Vernee
            lkuskov Leonid Kuskov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: