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

Ensure methods reached through a union are detected as reachable. #3102

Merged
merged 1 commit into from
Mar 17, 2019

Conversation

jemc
Copy link
Member

@jemc jemc commented Mar 17, 2019

Prior to this PR, the fact of whether methods of a union member were marked
as reachable when called via a union (or intersection) reference was
accidentally depending on the order in which things were marked
reachable in the compiler execution. When a type was marked
as a subtype of the union before the method call was reached,
everything was okay, but when that order was reversed
(possible through indirection of a trait), things were not okay -
the methods seen as reachable through the union weren't copied
into being reachable on the subtype of the union as they were
supposed to.

The result was the possibility of runtime segfaults when the
expected vtable entries were not present, as observed in #3096.

This PR fixes that by ensuring this copy happens. Prior to this PR,
the copy was only happening for traits and interface subtypes,
but now it happens for union and intersection subtypes too.

Resolves #3096.

Prior to this PR, the fact of whether methods of a union member were marked
as reachable when called via a union (or intersection) reference was
accidentally depending on the order in which things were marked
reachable in the compiler execution. When a type was marked
as a subtype of the union before the method call was reached,
everything was okay, but when that order was reversed
(possible through indirection of a trait), things were not okay -
the methods seen as reachable through the union weren't copied
into being reachable on the subtype of the union as they were
supposed to.

This PR fixes that by ensuring this copy happens. Prior to this PR,
the copy was only happening for traits and interface subtypes,
but now it happens for union and intersection subtypes too.

Resolves #3096.
@jemc jemc added triggers release Major issue that when fixed, results in an "emergency" release changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge labels Mar 17, 2019
@SeanTAllen
Copy link
Member

@jemc is the commit comment what you want for the release notes? if not, can you add release notes here?

@jemc
Copy link
Member Author

jemc commented Mar 17, 2019

Release Note

Prior versions of Pony contained a bug in code reachability analysis that caused deterministic runtime crashes due to undetected reachability of a method call under certain specific conditions, including:

  • the method being called only through a trait within a union type
  • the order of compilation causing the concrete type to be seen as reachable after reaching the method call

The issue has been fixed in this release, and it's recommended that all users update to prevent the possibility of such runtime crashes.

@SeanTAllen SeanTAllen merged commit eb52990 into master Mar 17, 2019
@SeanTAllen SeanTAllen deleted the fix/3096-reachability-of-union-member-methods branch March 17, 2019 14:26
ponylang-main added a commit that referenced this pull request Mar 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge triggers release Major issue that when fixed, results in an "emergency" release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Runtime segfault when calling a function on a (Trait | Other) type
3 participants