chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.79k stars 421 forks source link

AST-ITE-TOR-0522 internal error #15719

Open cassella opened 4 years ago

cassella commented 4 years ago

Using this script-internal-error.chpl

https://gist.github.com/cassella/5047b3ce3f846c1765dc064a2f38be27

With the kernel-matrix.chpl from

https://gist.github.com/dataPulverizer/5ee481d5a8215ddea42a08835c0d1efb

results in an internal error:

Compile command:

chpl kernelmatrix.chpl script-internal-error.chpl 
script-internal-error.chpl:91: internal error: assertion error [resolution/wrappers.cpp:1934]
Note: This source location is a guess.

(RES-WRA-ERS-1934)

// insert PRIM_ITERATOR_RECORD_SET_SHAPE(iterRecord,shapeSource)
static void addSetIteratorShape(PromotionInfo& promotion, CallExpr* call) {
  CallExpr* move = toCallExpr(call->parentExpr);
  // If call's result is not used, do not insert.
  // This happens, for example, during resolveSerializeDeserialize().
  if (move == NULL) return;
  INT_ASSERT(move->isPrimitive(PRIM_MOVE));
  Symbol* irTemp = toSymExpr(move->get(1))->symbol();

Source Code:

The error in my source code was

        tmp[2] = results.n[i][j]: string;
        tmp[3] = results.times[i][j]: string;

instead of

        tmp[2] = results[i].n[j]: string;
        tmp[3] = results[i].times[j]: string;

I assume it's trying to promote the field access over the results array in the bad version.

Associated Future Test(s): test/functions/iterators/errors/mistakenIteratorShape.chpl #21306

Configuration Information

chpl version 1.23.0 pre-release (f1900fc066)

CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native *
CHPL_LOCALE_MODEL: flat
CHPL_COMM: gasnet *
  CHPL_COMM_SUBSTRATE: udp
  CHPL_GASNET_SEGMENT: everything
CHPL_TASKS: qthreads
CHPL_LAUNCHER: amudprun
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_ATOMICS: cstdlib
  CHPL_NETWORK_ATOMICS: none
CHPL_GMP: gmp
CHPL_HWLOC: hwloc
CHPL_REGEXP: re2
CHPL_LLVM: none
CHPL_AUX_FILESYS: none

gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
cassella commented 1 year ago

I was able to reduce it, though the internal error it's hitting now is different.

[ edit: that is, when I revisited the original code on the date of this comment, the internal error it hit had changed. I was able to reduce the code down to this, hitting that same new error. ]

record BenchRecord {
  var D: domain(1);
  var n: [D] int(64);
  proc init()
  {
    this.D = {0..1};
    this.n = [0,1];
  }
}

var n = [100, 500, 100];
var results: [0..#1] BenchRecord;

for j in 0..n.size {
  // XXX: This was intended to be results[0].n[j]
  var tmp = results.n[0][j]: string;
}
foo.chpl:16: internal error: assertion error [AST//home/fortytwo/src/chapel/compiler/AST/iterator.cpp:522]

aka

foo.chpl:16: internal error: AST-ITE-TOR-0522 chpl version 1.30.0 pre-release (b'ae52de5bbc')
Note: This source location is a guess.

Internal errors indicate a bug in the Chapel compiler ("It's us, not you"),
and we're sorry for the hassle.  We would appreciate your reporting this bug --
please see https://chapel-lang.org/bugs.html for instructions.  In the meantime,
the filename + line number above may be useful in working around the issue.

which is in setIteratorRecordShape():

  if (field == NULL) {
...
  } else {
    INT_ASSERT(field->type == value->type);
  }