Program: 35274
Project: 35274
Buggy source:
@Test public void test64_K_queries_PositiveNumbers(){
  final int K=5;
  final int W=32;
  final int N=1000;
  for (int r=0; r < 100; r++) {
    Random R=new Random(r);
    long[][] aa=new long[N][];
    CritBit cb=newCritBit(W,K);
    for (int i=0; i < N; i++) {
      long[] a=new long[K];
      for (int k=0; k < K; k++) {
        a[k]=Math.abs(R.nextLong()) >>> (64 - W);
      }
      if (cb.containsKD(a)) {
        i--;
        continue;
      }
      aa[i]=a;
      assertTrue(cb.insertKD(a));
      if (!cb.containsKD(a)) {
        cb.printTree();
      }
      assertTrue(cb.containsKD(a));
    }
    assertEquals(N,cb.size());
    long[] qMin=new long[K];
    long[] qMax=new long[K];
    Iterator<long[]> it=null;
    for (int i=0; i < 10; i++) {
      createQuery(R,qMin,qMax);
      ArrayList<long[]> result=executeQuery(aa,qMin,qMax);
      it=cb.queryKD(qMin,qMax);
      int nResult=0;
      while (it.hasNext()) {
        long[] ra=it.next();
        nResult++;
        assertContains(aa,ra);
      }
      assertEquals("String_Node_Str" + r + "String_Node_Str"+ i,result.size(),nResult);
    }
    int n=0;
    Arrays.fill(qMin,Long.MIN_VALUE);
    Arrays.fill(qMax,Long.MAX_VALUE);
    it=cb.queryKD(qMin,qMax);
    while (it.hasNext()) {
      it.next();
      n++;
    }
    assertEquals(aa.length,n);
    for (    long[] a : aa) {
      it=cb.queryKD(a,a);
      assertTrue(it.hasNext());
      long[] r2=it.next();
      assertFalse(it.hasNext());
      assertTrue(isEqual(a,r2));
    }
    Arrays.fill(qMin,Long.MIN_VALUE);
    Arrays.fill(qMax,Long.MAX_VALUE);
    it=cb.queryKD(qMax,qMin);
    assertFalse(it.hasNext());
    for (    long[] a : aa) {
      assertTrue(cb.removeKD(a));
    }
    Arrays.fill(qMin,Long.MIN_VALUE);
    Arrays.fill(qMax,Long.MAX_VALUE);
    it=cb.queryKD(qMin,qMax);
    assertFalse(it.hasNext());
  }
}

Fixed version (ground truth):
@Test public void test64_K_queries_PositiveNumbers(){
  final int K=5;
  final int W=32;
  final int N=1000;
  for (int r=0; r < 100; r++) {
    Random R=new Random(r);
    long[][] aa=new long[N][];
    CritBit cb=newCritBit(W,K);
    for (int i=0; i < N; i++) {
      long[] a=new long[K];
      for (int k=0; k < K; k++) {
        a[k]=Math.abs(R.nextLong()) >>> (64 - W);
      }
      if (cb.containsKD(a)) {
        i--;
        continue;
      }
      aa[i]=a;
      assertTrue(cb.insertKD(a));
      assertTrue(cb.containsKD(a));
    }
    assertEquals(N,cb.size());
    long[] qMin=new long[K];
    long[] qMax=new long[K];
    Iterator<long[]> it=null;
    for (int i=0; i < 10; i++) {
      createQuery(R,qMin,qMax);
      ArrayList<long[]> result=executeQuery(aa,qMin,qMax);
      it=cb.queryKD(qMin,qMax);
      int nResult=0;
      while (it.hasNext()) {
        long[] ra=it.next();
        nResult++;
        assertContains(aa,ra);
      }
      assertEquals("String_Node_Str" + r + "String_Node_Str"+ i,result.size(),nResult);
    }
    int n=0;
    Arrays.fill(qMin,Long.MIN_VALUE);
    Arrays.fill(qMax,Long.MAX_VALUE);
    it=cb.queryKD(qMin,qMax);
    while (it.hasNext()) {
      it.next();
      n++;
    }
    assertEquals(aa.length,n);
    for (    long[] a : aa) {
      it=cb.queryKD(a,a);
      assertTrue(it.hasNext());
      long[] r2=it.next();
      assertFalse(it.hasNext());
      assertTrue(isEqual(a,r2));
    }
    Arrays.fill(qMin,Long.MIN_VALUE);
    Arrays.fill(qMax,Long.MAX_VALUE);
    it=cb.queryKD(qMax,qMin);
    assertFalse(it.hasNext());
    for (    long[] a : aa) {
      assertTrue(cb.removeKD(a));
    }
    Arrays.fill(qMin,Long.MIN_VALUE);
    Arrays.fill(qMax,Long.MAX_VALUE);
    it=cb.queryKD(qMin,qMax);
    assertFalse(it.hasNext());
  }
}