Open kylefurlong opened 1 year ago
Please post the code that you are reporting. It's not completely clear what changes are required to replicate the issue.
Hi Sean,
I'm somewhat flabbergasted. The posted code in the original comment crashes ponyc when adding a ^
to let c: T iso = ...
at line 19. The code that crashes would read let c: T iso^ = ...
.
Hoping I'm not the crazy one!
Best, Kyle
Kyle can you please post the complete code that crashes rather than a description of changes to code that is required to cause the situation?
Hi Sean,
It might sound crazy, but I actually did post the entire code that reproduces the issue in the first post. Any chance you can place the code in a test.pony file and try the edit I suggested?
No it doesn't…
actor Main
new create() =>
let c: T iso = TClass.create(l)
let a: Act = Act.create(c)
[red@apophenia:~/dd]$ ponyc
Building builtin -> /nix/store/nnvr2l04kdk62n633g74p0vdwf9bbrmy-ponyc-0.54.0/lib/pony/0.54.0/packages/builtin
Building . -> /home/red/dd
Error:
/home/red/dd/main.pony:19:38: can't find declaration of 'l'
let c: T iso = TClass.create(l)
The code you originally posted doesn't compile. We can't correct it to make it compile to follow your suggested edit because your problem description is related to incorrect capabilities.
We need to know what you compiled.
Also - can you confirm which version of ponyc you're using please?
I also noticed that your constructor for Main isn't correct either:
actor Main
new create() => // Should be new create(env: Env) =>
Policing the code isn't helpful. Just run it.
(base) kylefurlong@Kyles-Mac-mini quanta % cat ~/crash.pony
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() =>
let c: T iso^ = TClass.create("")
let a: Act = Act.create(c)
(base) kylefurlong@Kyles-Mac-mini quanta % ponyc ~
Building builtin -> /Users/kylefurlong/.local/share/ponyup/ponyc-release-0.53.0-arm64-darwin/packages/builtin
Building /Users/kylefurlong -> /Users/kylefurlong
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
zsh: segmentation fault ponyc ~
It's not policing code when what you originally provided (after edit) is this:
let c: T iso^ = TClass.create(l)
Which gives me:
[nix-shell:~/dd]$ ponyc
Building builtin -> /nix/store/nnvr2l04kdk62n633g74p0vdwf9bbrmy-ponyc-0.54.0/lib/pony/0.54.0/packages/builtin
Building . -> /home/red/dd
Error:
/home/red/dd/main.pony:19:47: can't find declaration of 'l'
let c: T iso^ = TClass.create(l)
Wheres in your last comment which actually illustrates the bug you have:
let c: T iso^ = TClass.create("")
So no, your original report, even after your requested edit did not replicate the compiler error.
However, your last comment (in which you actually provided the information we explicitly asked for - thank you) - did provide a version I could replicate the issue with.
So how about we take a step back from the inflammatory language and start again?
Ah, I see the mistake. I apologize for the unforgiving attitude and unkind words. I should have read your first response more carefully and then I could have corrected the original.
@redvers can you post the complete code for this bug?
@redvers ping. see above.
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.
A more minimal repro:
actor Main
new create() =>
let c: String iso^ = String
There's two things wrong with the minimal code:
ref
, not iso
- you'd need to wrap it in a recover to get an iso
iso^
is not a valid ref cap for a local variable (which the compiler rightly tells if you if you fix the above issue by wrapping in a recover block)So for either of these problems in isolation, the compiler will give you error messages correctly. It's only the combination of the two that gives the assertion failure encountered in this ticket.
@jemc Just a note, let c: String iso = String
is fine due to Gordon's work https://github.com/ponylang/ponyc/pull/4124
My guess is that change could be one of the components involved plus my last changes to iso^.
Adding a
^
tolet c: T iso = ...
causes a ponyc crash.