ponyc: Compile-time crash related to Pony-specific optimization passes
I’m new to both Pony and to programming in general, so I apologize in advance if this is some obvious error on my part.
I was trying to experiment with ponyc to learn more about the language constructs and what expressions typecheck. In so doing I think I managed to crash the compiler. Here is the code I was using on Fedora Linux with ponyc 0.42.0:
// act -- Counter as an actor
actor Counter
var _count : U32
new create() =>
_count = 0
be inc() =>
_count = _count + 1
be display(out : OutStream) =>
out.print(_count.string())
_count = 0
primitive Math
fun add(x : U64, y : U64): U64 =>
x + y
fun subtract(x : U64, y : U64): U64 =>
x - y
actor Main
new create(env : Env) =>
let c = Counter
c.inc()
c.display(env.out)
for animal in ["lions"; "tigers"; "bears"].values() do
env.out.print(animal)
end
And here is the error text this provoked in bash:
[zack@localhost act]$ ponyc
Building builtin -> /home/zack/.local/share/ponyup/ponyc-release-0.42.0-x86_64-linux-gnu/packages/builtin
Building . -> /home/zack/projs/act
Generating
Reachability
Selector painting
Data prototypes
Data types
Function prototypes
Functions
Descriptors
Optimising
/tmp/cirrus-ci-build/src/libponyc/codegen/genopt.cc:1236: makeMsgChains: Assertion `prev_msg == (*iter)->getArgOperand(3)` failed.
Backtrace:
ponyc(ponyint_assert_fail+0x82) [0x762c12]
ponyc(_ZN16MergeMessageSend13makeMsgChainsERKN4llvm11SmallVectorIPNS0_8CallInstELj16EEE+0x269) [0x6dff89]
ponyc(_ZN16MergeMessageSend15runOnBasicBlockERN4llvm10BasicBlockE+0x206) [0x6df4c6]
ponyc() [0x883207]
ponyc(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x44e) [0x87e77e]
ponyc() [0x1123cb1]
ponyc(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x53a) [0x87f05a]
ponyc(genopt+0x4c3) [0x6d9c93]
ponyc(genexe+0x218) [0x6c46a8]
ponyc(codegen+0xad) [0x6bc1fd]
ponyc(main+0x187) [0x6b1b07]
/lib64/libc.so.6(__libc_start_main+0xd5) [0x7f3829f6fb75]
ponyc(_start+0x2e) [0x6b18be]
This is an optimised version of ponyc: the backtrace may be imprecise or incorrect.
Use a debug version to get more meaningful information.
Stack dump:
0. Running pass 'CallGraph Pass Manager' on module 'act'.
1. Running pass 'BasicBlock Pass Manager' on function '@Main_Dispatch'
2. Running pass 'Group message sends in the same BasicBlock' on basic block '%Main_tag_create_oo.exit'
Aborted (core dumped)
[zack@localhost act]$
What seems to have provoked it were the three lines at the bottom with the iterator. If I comment them out – or if I comment out the three lines immediately above them – it compiles and runs normally. I confess that I don’t even know if I inadvertently wrote invalid code, but I would have expected some sort of syntax or type error rather than what looks like a dump from LLVM.
Please let me know if I should include other information.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (22 by maintainers)
Commits related to this issue
- Fix a compile-time crash related to Pony-specific optimizations. Ticket #3784 tracked an issue related the MergeMessageSend optimization pass, which does Pony-specific optimizations within the LLVM o... — committed to ponylang/ponyc by jemc 3 years ago
- Fix a compile-time crash related to Pony-specific optimizations. Ticket #3784 tracked an issue related the MergeMessageSend optimization pass, which does Pony-specific optimizations within the LLVM o... — committed to ponylang/ponyc by jemc 3 years ago
Last observation:
If you take this slightly different code-> It crashes.
However, if you switch the order of the
let a
andlet b
it doesn’t: