ponylang/ponyc

Segfault from bad cap in code

SeanTAllen opened this issue · 0 comments

          I stumbled on this while searching for clues on a similar (but unfortunately not identical) error. 

Here's the repro code and backtrace:

trait T
  fun some() =>
    "Do nothing"

class TClass is T
  let _l: String
  new create(l: String) =>
     _l = consume l
  fun some() =>
      "Do nothing"

actor Act
  let _c: T iso
  new create(c: T iso) =>
    _c = consume c

actor Main
  new create(env: Env) =>
    let c: T iso^ = TClass.create("")
    let a: Act = Act.create(consume c)

Fails with

# ponyc
Building builtin -> /usr/local/lib/pony/0.58.1-fe3895eb/packages/builtin
Building . -> /root/proj/scratch/pony/21-segfault
/root/proj/ponyc/src/libponyc/ast/ast.c:577: ast_id: Assertion `ast != NULL` failed.

Backtrace:
  ponyc(ponyint_assert_fail+0x9c) [0x89e49c]
  ponyc(ast_id+0x3b) [0x794a5b]
  ponyc(cap_fetch+0x15) [0x82c845]
  ponyc(expr_assign+0x244) [0x885714]
  ponyc(pass_expr+0x143) [0x7f6b53]
  ponyc(ast_visit+0x2aa) [0x7f78aa]
  ponyc(ast_visit+0x1e6) [0x7f77e6]
  ponyc(ast_visit+0x1e6) [0x7f77e6]
  ponyc(ast_visit+0x1e6) [0x7f77e6]
  ponyc(ast_visit+0x1e6) [0x7f77e6]
  ponyc(ast_visit+0x1e6) [0x7f77e6]
  ponyc(ast_visit+0x1e6) [0x7f77e6]
  ponyc(ast_visit+0x1e6) [0x7f77e6]
  ponyc() [0x7f83e6]
  ponyc() [0x7f7d75]
  ponyc(ast_passes_program+0x22) [0x7f7982]
  ponyc(program_load+0xbf) [0x81acef]
  ponyc() [0x793cf9]
  ponyc(main+0x270) [0x793b90]
  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f9cfc771083]
  ponyc(_start+0x2e) [0x79385e]
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Aborted

Using version 0.58.1-fe3895eb from the most recent release tag, running on Ubuntu 20.04 on Intel.

Originally posted by @nisanharamati in #4344 (comment)