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

Segfault #1474

Closed
SeanTAllen opened this issue Dec 16, 2016 · 3 comments
Closed

Segfault #1474

SeanTAllen opened this issue Dec 16, 2016 · 3 comments
Assignees

Comments

@SeanTAllen
Copy link
Member

SeanTAllen commented Dec 16, 2016

I haven't fully worked the why of this segfault:

Process 81526 stopped
* thread #2: tid = 0x568fa6, 0x0000000100072ed2 wallaroo`ponyint_messageq_push(q=0x00000001198f20c8, m=0x00000001198f27a0) + 82 at messageq.c:75, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
   frame #0: 0x0000000100072ed2 wallaroo`ponyint_messageq_push(q=0x00000001198f20c8, m=0x00000001198f27a0) + 82 at messageq.c:75
  72      #ifdef USE_VALGRIND
  73        ANNOTATE_HAPPENS_BEFORE(&prev->next);
  74      #endif
-> 75        atomic_store_explicit(&prev->next, m, memory_order_release);
  76
  77        return was_empty;
  78      }

Minimal case:

CRASHES:

use "ponytest"

trait tag Taggable
  be foo[In: Any val](i: In)

trait tag CFConsumer
  be bar() => None

type Consumer is CFConsumer

type TagableConsumer is (Taggable & Consumer)

class MockTaggable is TagableConsumer
  fun tag foo[In: Any val](i: In) =>
    this

  fun tag bar() =>
    this

primitive _X
  fun send[In: Any val](d: In, e: TagableConsumer) =>
    e.foo[In](d)

actor Main is TestList
  new create(env: Env) =>
    PonyTest(env, this)

  new make() =>
    None

  fun tag tests(test: PonyTest) =>
    test(_Test)

class iso _Test is UnitTest
  fun name(): String =>
    "test"

  fun apply(h: TestHelper) =>
    let tc = MockTaggable

    _X.send[ISize](ISize(10), tc)

Changing class MockTaggable to actor MockTaggable fixes the segfault and the test runs to completion.

Not calling tc.foo from inside the primitive also takes care of the issue:

DOESN'T CRASH:

use "ponytest"

trait tag Taggable
  be foo[In: Any val](i: In)

trait tag CFConsumer
  be bar() => None

type Consumer is CFConsumer

type TagableConsumer is (Taggable & Consumer)

actor MockTaggable is TagableConsumer
  fun tag foo[In: Any val](i: In) =>
    this

  fun tag bar() =>
    this

actor Main is TestList
  new create(env: Env) =>
    PonyTest(env, this)

  new make() =>
    None

  fun tag tests(test: PonyTest) =>
    test(_Test)

class iso _Test is UnitTest
  fun name(): String =>
    "test"

  fun apply(h: TestHelper) =>
    let tc = MockTaggable

    tc.foo[ISize](ISize(10))
@Praetonus
Copy link
Member

In the reachability data structure in the compiler, MockTaggable isn't in the subtype list of (Taggable & Consumer) (the DS is reach_type_t.subtypes). Then, the behaviour_in_every_subtype function doesn't see MockTaggable and treats the method call as a message send. I think that's a problem with the subtype assignment during the reachability pass.

@Praetonus
Copy link
Member

There seem to be a workaround for the problem, you can make TaggableConsumer a trait instead of a type alias.

@Praetonus
Copy link
Member

After looking into it, unions and intersections aren't picking up their subtypes during the reachability analysis.

@Praetonus Praetonus self-assigned this Feb 15, 2017
Praetonus pushed a commit to Praetonus/ponyc that referenced this issue Feb 15, 2017
This change ensures that unions and intersections pick up their
subtypes during the reachability analysis.

Closes ponylang#1474.
Praetonus pushed a commit to Praetonus/ponyc that referenced this issue Feb 15, 2017
This change ensures that unions and intersections pick up their
subtypes during the reachability analysis.

Closes ponylang#1474.
jemc pushed a commit that referenced this issue Feb 15, 2017
This change ensures that unions and intersections pick up their
subtypes during the reachability analysis.

Closes #1474.
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

No branches or pull requests

2 participants