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

Compilation segfault #2740

Open
Shorttail opened this issue Jun 4, 2018 · 7 comments
Open

Compilation segfault #2740

Shorttail opened this issue Jun 4, 2018 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed needs investigation This needs to be looked into before its "ready for work"

Comments

@Shorttail
Copy link

Shorttail commented Jun 4, 2018

Here's a minimal example.

actor Main
  new create(env: Env) =>
    foo()

  fun foo() =>
    @bar[None](addressof baz)

  fun baz() =>
    None

The error is the following:

Generating
 Reachability
c:\projects\ponyc\src\libponyc\type\cap.c:710: cap_view_upper: Assertion `0` failed.

Backtrace:
  () [00007FF72FDD375D]
  () [00007FF72FD8CE44]
  () [00007FF72FD8FE99]
  () [00007FF72FD8FA88]
  () [00007FF72FD8EE97]
  () [00007FF72FD8F844]
  () [00007FF72FD8F89D]
  () [00007FF72FD8869C]
  () [00007FF72FDA38D7]
  () [00007FF72FDA31CA]
  () [00007FF72FDA433C]
  () [00007FF72FDA4B73]
  () [00007FF72FDA4ED1]
  () [00007FF72FDA4ED1]
  () [00007FF72FDA548F]
  () [00007FF72FDAD342]
  () [00007FF72FD6C5FA]
  () [00007FF72FD3145F]
  () [00007FF72FD315E0]
  (pony_asio_event_set_writeable) [00007FF730E07A5C]
  (BaseThreadInitThunk) [00007FFE13E03034]
  (RtlUserThreadStart) [00007FFE141F1551]
This is an optimised version of ponyc: the backtrace may be imprecise or incorrect.
Use a debug version to get more meaningful information.

Moving the code from foo to create removes the segfault.
Removing the addressof this.baz from the arguments also removes the segfault.

Edit: All edits to reduce example code size.

@SeanTAllen
Copy link
Member

Can reproduce on OSX.

@SeanTAllen
Copy link
Member

backtrace:

* thread #1: tid = 0x113a57, 0x00007fff8c223f06 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff8c223f06 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fff8c223f06 <+10>: jae    0x7fff8c223f10            ; <+20>
    0x7fff8c223f08 <+12>: movq   %rax, %rdi
    0x7fff8c223f0b <+15>: jmp    0x7fff8c21e7cd            ; cerror_nocancel
    0x7fff8c223f10 <+20>: retq
(lldb) bt
* thread #1: tid = 0x113a57, 0x00007fff8c223f06 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff8c223f06 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff9a8224ec libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fff8ab476df libsystem_c.dylib`abort + 129
    frame #3: 0x00000001001250f3 ponyc`ponyint_assert_fail(expr="0", file="src/libponyc/type/cap.c", line=710, func="cap_view_upper") + 403 at ponyassert.c:60
    frame #4: 0x0000000100100c61 ponyc`cap_view_upper(left_cap=TK_AT, left_eph=TK_NONE, right_cap=0x00007fff5fbfe5cc, right_eph=0x00007fff5fbfe5c8) + 753 at cap.c:710
    frame #5: 0x0000000100110884 ponyc`viewpoint_upper(type=0x0000000107efd040) + 660 at viewpoint.c:221
    frame #6: 0x0000000100110563 ponyc`viewpoint_type(l_type=0x0000000107effc00, r_type=0x0000000107efd080) + 1587 at viewpoint.c:135
    frame #7: 0x0000000100110f8d ponyc`replace_type(astp=0x00007fff5fbfe8c8, target=0x0000000107f01a00, with=0x0000000107efd0c0) + 717 at viewpoint.c:377
    frame #8: 0x0000000100110cae ponyc`viewpoint_replace(ast=0x0000000107efd180, target=0x0000000107f01a00, with=0x0000000107efd0c0, duplicate=false) + 158 at viewpoint.c:398
    frame #9: 0x0000000100111015 ponyc`viewpoint_replacethis(ast=0x0000000107efd180, with=0x0000000107efd0c0, duplicate=false) + 69 at viewpoint.c:405
    frame #10: 0x0000000100106343 ponyc`deferred_reify(deferred=0x0000000107efc300, ast=0x000000010a2de240, opt=0x00007fff5fbff7e0) + 67 at reify.c:296
    frame #11: 0x00000001000f8dd3 ponyc`set_method_types(r=0x00000001082a0100, m=0x0000000107ef6880, opt=0x00007fff5fbff7e0) + 195 at reach.c:192
    frame #12: 0x00000001000f6dc6 ponyc`add_rmethod(r=0x00000001082a0100, t=0x0000000107efa900, n=0x0000000107ef6800, cap=TK_AT, typeargs=0x0000000000000000, opt=0x00007fff5fbff7e0, internal=false) + 502 at reach.c:371
    frame #13: 0x00000001000f7681 ponyc`add_nominal(r=0x00000001082a0100, type=0x0000000107efc040, opt=0x00007fff5fbff7e0) + 1249 at reach.c:914
    frame #14: 0x00000001000f6a4a ponyc`add_type(r=0x00000001082a0100, type=0x0000000107efc040, opt=0x00007fff5fbff7e0) + 186 at reach.c:990
    frame #15: 0x00000001000fa26a ponyc`reachable_ffi(r=0x00000001082a0100, reify=0x0000000107efeb80, ast=0x000000010ab550c0, opt=0x00007fff5fbff7e0) + 586 at reach.c:1135
    frame #16: 0x00000001000f93f5 ponyc`reachable_expr(r=0x00000001082a0100, reify=0x0000000107efeb80, ast=0x000000010ab550c0, opt=0x00007fff5fbff7e0) + 597 at reach.c:1196
    frame #17: 0x00000001000f9a47 ponyc`reachable_expr(r=0x00000001082a0100, reify=0x0000000107efeb80, ast=0x000000010ab54bc0, opt=0x00007fff5fbff7e0) + 2215 at reach.c:1307
    frame #18: 0x00000001000f64ac ponyc`handle_method_stack(r=0x00000001082a0100, opt=0x00007fff5fbff7e0) + 108 at reach.c:1383
    frame #19: 0x00000001000f61b2 ponyc`reach(r=0x00000001082a0100, type=0x00000001082a3340, name="create", typeargs=0x0000000000000000, opt=0x00007fff5fbff7e0) + 82 at reach.c:1413
    frame #20: 0x000000010004f973 ponyc`genexe(c=0x00007fff5fbff2e8, program=0x000000010b1bfd40) + 435 at genexe.c:504
    frame #21: 0x000000010003dd2e ponyc`codegen(program=0x000000010b1bfd40, opt=0x00007fff5fbff7e0) + 302 at codegen.c:874
    frame #22: 0x00000001000cc013 ponyc`generate_passes(program=0x000000010b1bfd40, options=0x00007fff5fbff7e0) + 51 at pass.c:360
    frame #23: 0x0000000100001c91 ponyc`compile_package(path=".", opt=0x00007fff5fbff7e0, print_program_ast=false, print_package_ast=false) + 177 at main.c:67
    frame #24: 0x0000000100001abc ponyc`main(argc=1, argv=0x00007fff5fbff8d8) + 316 at main.c:108
    frame #25: 0x00007fff9e1ad5ad libdyld.dylib`start + 1

@SeanTAllen
Copy link
Member

The following also compiles:

actor Main
  new create(env: Env) =>
    foo()

  fun foo() =>
    None

  fun baz() =>
    @bar[None](addressof baz)

@jemc
Copy link
Member

jemc commented Jul 11, 2018

Could be related to the deferred_reify changes that @Praetonus worked on somewhat recently?

@SeanTAllen
Copy link
Member

Can someone test this with code prior to #2557 being merged to master? If using a release, that would be 0.21.3?

@SeanTAllen
Copy link
Member

I tested this with 0.21.3 and it crashes as well, so not introduced by #2557.

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

Still present as of 0.37.0

@SeanTAllen SeanTAllen added the help wanted Extra attention is needed label Sep 5, 2020
@SeanTAllen SeanTAllen changed the title Segfault while compiling on windows with pony 0.22.3 Compilation segfault Sep 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed needs investigation This needs to be looked into before its "ready for work"
Projects
None yet
Development

No branches or pull requests

4 participants