ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.74k stars 415 forks source link

Consume on LHS of assignment causes segfault #3463

Closed ivanbakel closed 4 years ago

ivanbakel commented 4 years ago

I was experimenting with how Pony handles paths on the LHS of an assignment which have side-effects, and I managed to trip over this compiler bug.

System

Linux 5.4.2-gnu-1 #1 SMP PREEMPT Fri, 06 Dec 2019 00:53:00 +0000 unknown GNU/Linux

The distribution is Parabola, a free Arch variant. Unless packages contain non-free software, they are normally sourced directly from Archlinux instead of being repackaged.

Compiler version

0.33.1 [release]
compiled with: llvm 7.1.0 -- cc (GCC) 9.2.0
Defaults: pic=true

Minimal Example

actor Main
  new create(env: Env val) =>
    let f : Foo iso = recover Foo end

    (consume f).b = recover Bar end

class Foo
  var b: Bar iso

  new create() =>
    b = recover Bar end

class Bar
  new create() => None

Expected Result

There's nothing inherently wrong with the code as written, I think - so it should compile, even if it is a bit nonsensical and people should be discouraged from writing it in production.

Compiler Output

Building builtin -> /usr/lib/pony/0.33.1/packages/builtin
Building . -> ...
src/libponyc/pass/refer.c:135: generate_multi_dot_name: Assertion `0` failed.

Backtrace:
   ...
Aborted (core dumped)
mfelsche commented 4 years ago

Thanks for the detailed report. I think this is the same assertion as is being hit in #3453.

SeanTAllen commented 4 years ago

@kapilash has a PR that fixes #3453. It does not however fix this. So this is probably not the same issue (although it might be similar).