Chapel: Internal compiler error in user-defined follower iterator with `in` intent

Created on 4 Jun 2019  路  3Comments  路  Source: chapel-lang/chapel

Summary of Problem

The code below causes an internal error. Removing the in intent fixes the error here.

Steps to Reproduce

Source Code:

class M {
  /* Parallel follow iterator.

     The serial and leader versions of this trigger a compiler error. 
  */
  iter follow(in dist) {
    halt("The follow iterator does not make sense in a serial context");
  }

  iter follow(param tag: iterKind, in dist) 
    where tag==iterKind.leader
    {
     halt("The follow iterator does not make sense in a leader context");
    }

  iter follow(param tag: iterKind, in dist, followThis)
    where tag==iterKind.follower
    {
     const dom = {(...followThis)};
     for ii in dom do yield 123;
    }

}

record G {
}

var g = new G();
var r = new owned M();
var arr : [1..4, 1..4] real;
forall (x1,r1) in zip(arr, r.follow(g)) do x1=r1;

Compile command:
chpl foo.chpl

fails with

internal error: UTI-MIS-0602 chpl version 1.19.0

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.

Compiling with chpl --devel foo.chpl yields

internal error: seg fault [util/misc.cpp:602]

If I remove the in intent (or make it a const), it compiles and works just fine.

Configuration Information

chpl version 1.19.0

Compiler Bug user issue

All 3 comments

Running this in valgrind, I saw reads to invalid data (never allocated) in the copyPropagation pass. @vasslitvinov, you look like you've worked in this file most recently. Would you be willing to take a quick look and see if the cause is obvious?

Running with --verify, there is a proper INT_FATAL in verification at the end of lowerIterators().

I am taking a quick look.

Background: our _toFollower function invokes the follower iterator passing to it the formals of the serial iterator. This gets the job done, however it is a poor representation because it uses those formals outside of their scope. lowerIterators removes these references by replacing them with fields of the corresponding _iteratorClass.

This replacement appears to miss dist in this case. The unique characteristic of the above reproducer is that it passes a record by in intent into an iterator that is subject to _toFollower. Resolution's insertion of a formal temp for this formal probably throws off the replacement code. To resolve this, we should probably adjust the latter.

Was this page helpful?
0 / 5 - 0 ratings