-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Neo VM Bug] Fix negative counter issue #3327
base: master
Are you sure you want to change the base?
Changes from 1 commit
d03e02a
f00012e
c7431a1
838ec24
655e4ca
dbd2993
f539ee7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -115,12 +115,12 @@ internal int CheckZeroReferred() | |||||
tracked_items.Remove(item); | ||||||
if (item is CompoundType compound) | ||||||
{ | ||||||
references_count -= compound.SubItemsCount; | ||||||
foreach (StackItem subitem in compound.SubItems) | ||||||
{ | ||||||
if (component.Contains(subitem)) continue; | ||||||
if (!NeedTrack(subitem)) continue; | ||||||
subitem.ObjectReferences!.Remove(compound); | ||||||
references_count--; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect references removal to be symmetric wrt references addition. And currently it's asymmetric because there's neo/src/Neo.VM/ReferenceCounter.cs Lines 49 to 50 in b1d27f0
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, maybe we need to move the line before that if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It fails if is symmetric, we get a negative counter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thing that I'm worried about is that we should find the reason why symmetric approach doesn't work. Right now I don't completely understand it.
shargon marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
} | ||||||
item.Cleanup(); | ||||||
|
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.
this ensures that it can be properly removed, but i think there is also problem of adding reference.
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.
Do you have an example?
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.
I believe if it goes negative it means the item was
never
met from previous oneStackItem
. You can use theCachedComponents
to see.