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

fix refcounts during comms addEgress #3485

Merged
merged 4 commits into from
Jul 22, 2021
Merged

Conversation

warner
Copy link
Member

@warner warner commented Jul 17, 2021

The comms addEgress function was calling setReachable with the wrong value for isImportFromComms. When we add an egress, the kernel is exporting an object into comms, and comms is exporting that to the downstream machine. So the downstream machine is importing it from comms (which means the isReachable flag causes the reachable refcount to be increased, something that only happens on imports, not on the export).

This caused the object being exported through addEgress to have a zero refcount. If/when the downstream machine ever dropped it, the refcount would go negative, causing an error.

fixes #3483

I recommend reviewing this one commit at a time. The second commit is a non-behavior-changing renaming which would distract from the important changes.

@warner warner added the SwingSet package: SwingSet label Jul 17, 2021
@warner warner added this to the Testnet: Metering Phase milestone Jul 17, 2021
@warner warner requested a review from FUDCo July 17, 2021 01:56
@warner warner self-assigned this Jul 17, 2021
@warner warner force-pushed the 3483-comms-add-egress-refcount branch from 0ade5dd to 417c50a Compare July 17, 2021 04:30
@warner warner changed the base branch from master to 3240-better-gc-and-finalize July 17, 2021 04:30
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After all that buildup I expected this to be more complicated :-)

@warner warner force-pushed the 3483-comms-add-egress-refcount branch from 417c50a to 2a7a702 Compare July 22, 2021 06:35
@warner warner force-pushed the 3240-better-gc-and-finalize branch from 1fee5ef to c80e6c7 Compare July 22, 2021 08:29
@warner warner force-pushed the 3483-comms-add-egress-refcount branch from 2a7a702 to 2981a8a Compare July 22, 2021 08:29
Base automatically changed from 3240-better-gc-and-finalize to master July 22, 2021 09:00
warner added 4 commits July 22, 2021 08:38
To make it easier to read, so I don't mess up the polarity again.

This should not cause any behavioral changes.
* expose state.getRefCounts() for debugging and tests
`addEgress` was calling `setReachable` with the wrong value for
`isImportFromComms`. When we add an egress, the kernel is exporting an object
into comms, and comms is exporting that to the downstream machine. So the
downstream machine is *importing* it from comms (which means the
`isReachable` flag causes the `reachable` refcount to be increased, something
that only happens on imports, not on the export).

This caused the object being exported through `addEgress` to have a zero
refcount. If/when the downstream machine ever dropped it, the refcount would
go negative, causing an error.

fixes #3483
@warner warner force-pushed the 3483-comms-add-egress-refcount branch from 2981a8a to 230b494 Compare July 22, 2021 15:39
@warner warner enabled auto-merge July 22, 2021 15:41
@warner warner merged commit 59a78e6 into master Jul 22, 2021
@warner warner deleted the 3483-comms-add-egress-refcount branch July 22, 2021 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

comms doesn't mark addEgress as "reachable"
2 participants