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

Vector API triggers SIGSEGV

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      I've tested it on Linux 6.0 AMD64 and Mac ARM64

      A DESCRIPTION OF THE PROBLEM :
      While developing a tokenizer and character detection library based on the Vector API, i came across a strange segfault. I nailed it down to the testcase below. If your maschine differs you may increase one the loop counters to trigger the bug. I can trigger it always on two recent laptops.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      If you run the test case it crashes after a certain round with a SIGSEGV if you change the line:

      for (int j = 0; j < lit_len; j++) {

      into
      for (int j = 0; j < 5; j++) {

      it will work.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I should work always despite the variable.
      ACTUAL -
      SIGSEGV and jvm crash

      ---------- BEGIN SOURCE ----------
      package org.knownhosts.libfindchars;

      import java.net.URISyntaxException;

      import org.junit.jupiter.api.Assertions;
      import org.junit.jupiter.api.BeforeEach;
      import org.junit.jupiter.api.Test;

      import jdk.incubator.vector.ByteVector;
      import jdk.incubator.vector.Vector;
      import jdk.incubator.vector.VectorOperators;

      public class TestVectorCrash {

          int lit_len;
          
          @BeforeEach
          void setup() {
           lit_len=5;
          }
          
          
      class TestOP {
      public Vector<Byte> find(){

      var reduced = ByteVector.SPECIES_PREFERRED.broadcast(0L);
      int rounds = 1_000;

      for (int i = 0; i < rounds; i++) {
      var buf = ByteVector.SPECIES_PREFERRED.broadcast(0L);

      for (int j = 0; j < lit_len; j++) {
               var vOnlyLiteral = ByteVector.SPECIES_PREFERRED.broadcast(-64L);
               reduced = reduced.add(buf, vOnlyLiteral.compare(VectorOperators.EQ, 0));
      }

      }
      return reduced;
      }
      }

      @Test
      public void crashes() throws URISyntaxException, Exception {

      var op = new TestOP();
      for (int i = 0; i < 2_000; i++) {
      System.out.println(i);
      var reduced = op.find();
      Assertions.assertNotNull(reduced);
      }

      }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      non exists to my knowledge

      FREQUENCY : always


            chagedorn Christian Hagedorn
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: