-
Notifications
You must be signed in to change notification settings - Fork 375
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
fix(gnovm): change initialization order so realm objects are persisted before referenced by other realms #1861
Conversation
This reverts commit e34a322.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1861 +/- ##
==========================================
+ Coverage 48.25% 48.27% +0.02%
==========================================
Files 408 409 +1
Lines 62338 62360 +22
==========================================
+ Hits 30081 30106 +25
+ Misses 29749 29737 -12
- Partials 2508 2517 +9 ☔ View full report in Codecov by Sentry. |
Marking as draft until the failing tests are fixed. I took a brief look and I see two categories of failing tests -- I may be completely wrong about these and will need to spend more time looking at them.
I think this change exposes a known issue with trying to assign a value to a nil realm pointer variable that is of a declared type -- #1326 |
gnovm/pkg/gnolang/machine.go
Outdated
} | ||
|
||
// RunFilesWithMemPkg is almost the same as RunFiles; the difference is that it | ||
// saves the mempackage to the store. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name is inconsistent with its behavior though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gut tells me not to add saving logic into runFiles logic, but instead runFiles could return new init functions as []Name, and the caller can save before or after as needed.
I'mstill trying to wrap my head around why it's needed. thinking..
back on this. |
…to fix/shared-realm-pointers
@mvertes @petar-dambovaliev please look into this |
Closing; #2255 also fixed this issue. |
Closes #974.
The first part of this PR addresses the issue linked above. The issue details a scenario in which pointer ownership was able to be stolen by passing the pointer value to another realm that saved the value to it's own realm during initialization. The solution for this is to persist the mem package before running any
init
functions. This should be fine because realm finalization happens the same number of times.The realm initialization behavior before (still the behavior for packages):
init
functionNew behavior for realms:
init
functionThe second part of this PR attempts to clarify what the expected behavior should be when sharing pointers to values amongst realms. It achieves this by updating the effective gno docs to detail the expected behavior and to generally discourage users from doing things like this unless there is a good reason to do so and they have a strong understanding of how this is expected to work. There are also clarifying txtar tests that have been added to test the expected behavior.TODO: remove the above docs changes. It was decided not to allow realms to store references to objects in other realms -- #2332
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description