Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure with annotations #1751

Closed
Praetonus opened this issue Mar 24, 2017 · 2 comments · Fixed by #1757
Closed

Assertion failure with annotations #1751

Praetonus opened this issue Mar 24, 2017 · 2 comments · Fixed by #1757
Assignees

Comments

@Praetonus
Copy link
Member

Minimal example:

actor Main
  new create(env: Env) =>
    if \likely\ U32(1) == 1 then
      None
    end

Using annotations on an expression results in an assertion failure:

src/libponyc/ast/ast.c:737: setannotation: Assertion `!hasparent(annotation) && (annotation->annotation_type == NULL)` failed.

Backtrace:

#2  0x0000000000502349 in ponyint_assert_fail (expr=0x50a12c "!hasparent(annotation) && (annotation->annotation_type == NULL)", file=0x509f07 "src/libponyc/ast/ast.c", 
    line=743, func=0x50a11e "setannotation") at src/libponyrt/platform/ponyassert.c:60
#3  0x0000000000432ddb in setannotation (ast=0x7ffff0559300, annotation=0x7ffff0490d80, allow_free=true) at src/libponyc/ast/ast.c:742
#4  0x0000000000433022 in ast_setannotation (ast=0x7ffff0559300, annotation=0x7ffff0490d80) at src/libponyc/ast/ast.c:769
#5  0x0000000000431cb0 in duplicate (parent=0x7ffff0524a80, ast=0x7ffff2f47c40) at src/libponyc/ast/ast.c:361
#6  0x0000000000431d1c in duplicate (parent=0x7ffff0524a80, ast=0x7ffff2f495c0) at src/libponyc/ast/ast.c:368
#7  0x0000000000431d1c in duplicate (parent=0x7ffff0524a80, ast=0x7ffff2f49bc0) at src/libponyc/ast/ast.c:368
#8  0x0000000000431c7c in duplicate (parent=0x7ffff0492cc0, ast=0x7ffff2f48a40) at src/libponyc/ast/ast.c:359
#9  0x0000000000431d1c in duplicate (parent=0x7ffff0492cc0, ast=0x7ffff2f49e80) at src/libponyc/ast/ast.c:368
#10 0x0000000000431d1c in duplicate (parent=0x7ffff0492cc0, ast=0x7ffff2f473c0) at src/libponyc/ast/ast.c:368
#11 0x0000000000431d1c in duplicate (parent=0x7ffff0492cc0, ast=0x7ffff2f49d80) at src/libponyc/ast/ast.c:368
#12 0x0000000000431d1c in duplicate (parent=0x7ffff0492cc0, ast=0x7ffff2f4a080) at src/libponyc/ast/ast.c:368
#13 0x0000000000431d1c in duplicate (parent=0x7ffff0492cc0, ast=0x7ffff2f4a7c0) at src/libponyc/ast/ast.c:368
#14 0x0000000000431d1c in duplicate (parent=0x7ffff0492cc0, ast=0x7ffff2f4a780) at src/libponyc/ast/ast.c:368
#15 0x0000000000431c7c in duplicate (parent=0x0, ast=0x7ffff2f4a6c0) at src/libponyc/ast/ast.c:359
#16 0x0000000000431b4c in ast_dup (ast=0x7ffff2f4a6c0) at src/libponyc/ast/ast.c:452
#17 0x00000000004e11f4 in viewpoint_replace (ast=0x7ffff2f4a6c0, target=0x7ffff0534b40, with=0x7ffff0562480) at src/libponyc/type/viewpoint.c:388
#18 0x00000000004e1545 in viewpoint_replacethis (ast=0x7ffff2f4a6c0, with=0x7ffff0562480) at src/libponyc/type/viewpoint.c:396
#19 0x00000000004f2c9a in lookup_nominal (opt=0x7fffffffe258, from=0x7ffff0562480, orig=0x7ffff0562480, type=0x7ffff0562480, name=0x7ffff3527f40 "create", errors=true)
    at src/libponyc/type/lookup.c:161
#20 0x00000000004f20c4 in lookup_base (opt=0x7fffffffe258, from=0x7ffff0562480, orig=0x7ffff0562480, type=0x7ffff0562480, name=0x7ffff3527f40 "create", errors=true)
    at src/libponyc/type/lookup.c:355
#21 0x00000000004f1f37 in lookup (opt=0x7fffffffe258, from=0x7ffff0562480, type=0x7ffff0562480, name=0x7ffff3527f40 "create") at src/libponyc/type/lookup.c:384
#22 0x0000000000485cc6 in genexe (c=0x7fffffffdda8, program=0x7ffff352fd40) at src/libponyc/codegen/genexe.c:382
#23 0x000000000046b47b in codegen (program=0x7ffff352fd40, opt=0x7fffffffe258) at src/libponyc/codegen/codegen.c:1000
#24 0x000000000044b4c3 in generate_passes (program=0x7ffff352fd40, options=0x7fffffffe258) at src/libponyc/pass/pass.c:291
#25 0x000000000043099d in compile_package (path=0x50cd5e ".", opt=0x7fffffffe258, print_program_ast=false, print_package_ast=false) at src/ponyc/main.c:245
#26 0x00000000004307d4 in main (argc=1, argv=0x7fffffffe3c8) at src/ponyc/main.c:367

It looks like the annotation node gets a type assigned to it. It doesn't happen when annotating a type declaration, only when annotating an expression.

According to git bisect, this bug was introduced in f788bb9.

@jemc
Copy link
Member

jemc commented Mar 24, 2017

Yep, this assert was introduced in #1649, but the weird behaviour of the annotation being assigned a type may have existed before the assert was present.

Is there any legitimate reason for an annotation node to get a type assigned to it? I think not, but just wanted to confirm with you.

@Praetonus
Copy link
Member Author

I don't think there is. I tried to look where the annotation was getting a type assigned to it but I couldn't find the location.

@jemc jemc self-assigned this Mar 24, 2017
jemc added a commit that referenced this issue Mar 26, 2017
Fixes #1751, a compiler assertion error related to this system.
Praetonus pushed a commit that referenced this issue Mar 27, 2017
Fixes #1751, a compiler assertion error related to this system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants