-
-
Notifications
You must be signed in to change notification settings - Fork 416
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
Capability violation with tuple recovery #1123
Comments
Recovering tuples could lead to reference capability violations. Closes ponylang#1123.
#1124 is intended to fix this bug by disallowing tuple recovery in all cases, but I personally wouldn't want to see this happen unless we're sure this is the best solution. I think there are lots of legitimate places where we can recover tuples, and indeed - cases where recovering tuples is the only sane way to recover multiple objects that have to be constructed in the same block, or are otherwise linked in some way. @Gds12 @sylvanc - are there any relatively-easy-to-implement rules we can use in the compiler to use to determine if a given tuple is safe to recover? Even if we can't be fully permissive, it seems like we could at least allow object references that are provably unrelated to one another (if it's possible to prove this). Any ideas? |
Recovering to other types could lead to reference capability violations. Closes ponylang#1123.
I think I've figured out the most permissive way of doing this, which is more or less as we discussed in the call last week with a few amendments:
Summary of examples:
Additionally, if the components of the tuple do not share any fields (including fields of fields etc...) then it should be safe to recover both members to iso^ as is currently done. For example a tuple of type Thoughts? Since I'm not too familiar with the actual implementation I may be missing something :) |
I'd like to be able to allow this, but I'm not sure how this would be checked in practice. Theoretically, it should be possible for the compiler to determine this, with the caveat that the no-sharing-of-fields would have to be enforced for every branch of conditional logic - the compiler can't know statically which branch will be executed at runtime, so all branches would have to be safe. However, in practice, this tracing of possible branches of execution would have to be done passing into functions, deeply, and tracking state in the tracing about which references could be common at any point. I don't think this is practically feasible with the current architecture of the compiler, unless someone has a clever trick to avoid this. So that said, I think we'll have to use only the first two points that @Gds12 suggested. I'll move further discussion of this into #1124, where it looks like @Praetonus has already gotten started. |
Recovering to other types could lead to reference capability violations. Closes ponylang#1123.
From today VUG presentation.
This program compiles but is clearly wrong (
ref
andval
aliases to the same object).The text was updated successfully, but these errors were encountered: