New Issue: string cast bus error probably due to reference cycle

20710, "mstrout", "string cast bus error probably due to reference cycle", "2022-09-23T19:46:15Z"

Summary of Problem

When I create a reference cycle between two class instances and then cast one of those instances to a string, a bus error occurs.

Better behavior would be to detect the infinite loop and possibly throw an exception or print an error?

Steps to Reproduce

Source Code:

class Node {
 var val : string;
 var other : shared Node?;
}
var n1 = new shared Node("node 1",nil);
var n2 = new shared Node("node 2",n1);
n1.other = n2;
writeln(n1:string); // THIS causes a bus error before printing anything out.

Compile command:
chpl foo.chpl

Execution command:
./foo

Configuration Information

  • Output of chpl --version:
chpl version 1.28.0
  built with LLVM version 14.0.6
Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright 2004-2019 Cray Inc.
(See LICENSE file for more details)

I am using the homebrew install of 1.28.0.