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

Another way to crash ponyc #3529

Open
damon-kwok opened this issue Apr 28, 2020 · 11 comments
Open

Another way to crash ponyc #3529

damon-kwok opened this issue Apr 28, 2020 · 11 comments
Labels
bug Something isn't working needs investigation This needs to be looked into before its "ready for work"

Comments

@damon-kwok
Copy link
Contributor

damon-kwok commented Apr 28, 2020

  • Note, Operating system independent, version independent.
  • Note, It must appear under multiple files, and it will not happen if the code is merged into one file
  • This is my minimal example:
    main.pony
actor Main
  let _env: Env
  new create(env: Env) =>
    _env = env

any_map.pony:

use "collections"
class FooMap[K, V]
  let _f_hash: ({(box->K!): USize} val | HashFunction[box->K!] val)

  new create(f: ({(box->K!): USize} val | HashFunction[box->K!] val)
    = {(key: box->K!): USize =>
    match key
      | let key': HashFunction[box->A!] val => key'.hash(key) //Note, `box->A!` Successfully broke ponyc
      | let key': Hashable val => key'.hash()
    end; 0} val) =>
    _f_hash = f

any_set.pony:

use "collections"
class FooSet[A: Any #read]
  embed _map: FooMap[A!, A]
  let _f_hash: ({(box->A!): USize} val | HashFunction[box->A!] val)

  new create(f: ({(box->A!): USize} val | HashFunction[box->A!] val)
    = {(key: box->A!): USize =>
    match key
      | let key': HashFunction[box->A!] val => key'.hash(key)
      | let key': Hashable val => key'.hash()
    end; 0}) =>
    _f_hash = f
    _map = _map.create(f)
-*- mode: compilation; default-directory: "~/projects/pp6/" -*-
Compilation started at Tue Apr 28 15:17:07

ponyc
Building builtin -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\builtin
Building . -> d:\msys64\home\damon\projects\pp6
Building collections -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\collections
Building ponytest -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\ponytest
Building time -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\time
Building random -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\random
D:\msys64\home\damon\.ome_local\repo\ponyc-git\src\libponyc\ast\ast.c:901: ast_has_annotation: Assertion `ast != NULL` failed.

Backtrace:
  () [00007FF6B88D0384]
  () [00007FF6B8820505]
  () [00007FF6B8882D5A]
  () [00007FF6B888BFFA]
  () [00007FF6B8840A18]
  () [00007FF6B8824925]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B88248C7]
  () [00007FF6B882425E]
  () [00007FF6B8824669]
  () [00007FF6B8827E71]
  () [00007FF6B881C4E4]
  () [00007FF6B881C6D2]
  (pony_asio_event_set_writeable) [00007FF6B948DEB4]
  (BaseThreadInitThunk) [00007FFE9E167BD4]
  (RtlUserThreadStart) [00007FFE9E68CE51]
This is an optimised version of ponyc: the backtrace may be imprecise or incorrect.
Use a debug version to get more meaningful information.

Compilation exited abnormally with code 9 at Tue Apr 28 15:17:10
@SeanTAllen
Copy link
Member

I'm unable to verify on Ubuntu 18.04 with 0.33.1. I get the correct syntax error message.

@SeanTAllen
Copy link
Member

Can't replicate on Ubuntu 18.04 with latest master. I get the correct syntax error message.

@SeanTAllen
Copy link
Member

@damon-kwok you'll need to provide more detailed replication instructions.

@damon-kwok
Copy link
Contributor Author

damon-kwok commented May 8, 2020

@SeanTAllen
OS: Windows10
Ponyc: 0.33.2 0.34.1

ponyc --version
0.34.1-87b473d [release]
Compiled with: LLVM 9.0.1 -- MSVC-19.26.28803.1-x64 1926
ponyc
Building builtin -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\builtin
Building . -> d:\msys64\home\damon\workspace\projects\pony\crash_ast
Building collections -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\collections
Building ponytest -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\ponytest
Building time -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\time
Building random -> D:\msys64\home\damon\.ome_local\repo\ponyc-git\build\install\packages\random
D:\msys64\home\damon\.ome_local\repo\ponyc-git\src\libponyc\ast\ast.c:901: ast_has_annotation: Assertion `ast != NULL` failed.

Backtrace:
  () [00007FF616C70394]
  () [00007FF616BC0515]
  () [00007FF616C22D6A]
  () [00007FF616C2C00A]
  () [00007FF616BE0A28]
  () [00007FF616BC4935]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC48D7]
  () [00007FF616BC426E]
  () [00007FF616BC4679]
  () [00007FF616BC7E81]
  () [00007FF616BBC4E4]
  () [00007FF616BBC6E1]
  (pony_asio_event_set_writeable) [00007FF61782DEC4]
  (BaseThreadInitThunk) [00007FFE9E167BD4]
  (RtlUserThreadStart) [00007FFE9E68CE51]
This is an optimised version of ponyc: the backtrace may be imprecise or incorrect.
Use a debug version to get more meaningful information.

Compilation exited abnormally with code 9 at Fri May  8 10:58:18

@SeanTAllen
Copy link
Member

@kulibali can you see if you get an error with a windows build?

@chalcolith
Copy link
Member

Yeah, I can repro this on Windows.

@SeanTAllen
Copy link
Member

@kulibali what's a better title for this issue?

@jemc
Copy link
Member

jemc commented May 12, 2020

Given that this is in ast_has_annotation. This is probably in the codegen pass, which might help explain why it only occurs on windows - that's one of the only places in the compiler that is platform-specific.

Sylvan also noted in today's sync call that the reference to asio in the backtrace is probably a red herring because it isn't involved in ponyc - probably the backtrace addresses being totally bogus and just happening to match a function or two by coincidence.

@chalcolith
Copy link
Member

Here's a debug backtrace:

Building builtin -> C:\Users\Gordon\Dev\Pony\ponyc_llvm901\packages\builtin
Building . -> C:\Users\Gordon\Dev\Pony\ponyc_llvm901\build\test_3529
Building collections -> C:\Users\Gordon\Dev\Pony\ponyc_llvm901\packages\collections
Building ponytest -> C:\Users\Gordon\Dev\Pony\ponyc_llvm901\packages\ponytest
Building time -> C:\Users\Gordon\Dev\Pony\ponyc_llvm901\packages\time
Building random -> C:\Users\Gordon\Dev\Pony\ponyc_llvm901\packages\random
C:\Users\Gordon\Dev\Pony\ponyc_llvm901\src\libponyc\ast\ast.c:901: ast_has_annotation: Assertion `ast != NULL` failed.

Backtrace:
  (ponyint_assert_fail) [00007FF6A689C46F]
  (ast_has_annotation) [00007FF6A674123D]
  (is_bare) [00007FF6A67DBE85]
  (is_bare) [00007FF6A67DBE9E]
  (check_constraints) [00007FF6A67E6E9D]
  (expr_nominal) [00007FF6A67F89E5]
  (pass_expr) [00007FF6A6784A13]
  (ast_visit) [00007FF6A67490FA]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (ast_visit) [00007FF6A6749036]
  (visit_pass) [00007FF6A6749484]
  (ast_passes) [00007FF6A67498F0]
  (ast_passes_program) [00007FF6A6748B68]
  (program_load) [00007FF6A674ADCF]
  (compile_package) [00007FF6A673BFEC]
  (main) [00007FF6A673C295]
  (__scrt_common_main_seh) [00007FF6A7AA5B5C]
  (BaseThreadInitThunk) [00007FF80E8E7BD4]
  (RtlUserThreadStart) [00007FF80F36CE51]

@jemc
Copy link
Member

jemc commented May 12, 2020

Thanks, Gordon.
So I was wrong about it being in codegen - it's in the expr pass.

@SeanTAllen SeanTAllen added needs investigation This needs to be looked into before its "ready for work" bug Something isn't working and removed windows labels May 12, 2020
@jemc
Copy link
Member

jemc commented May 12, 2020

You may (or may not) be able to fix this crash by modifying this line:

if(is_bare(typearg))

To look like:

 if(typearg && is_bare(typearg))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigation This needs to be looked into before its "ready for work"
Projects
None yet
Development

No branches or pull requests

4 participants