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

vm: fix incorrect refcounting in POPITEM #3688

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

roman-khimov
Copy link
Member

We're popping an item (array) off the stack, OK, it triggers refs.Remove() for it. Then we're pushing an inner item to the stack, OK, it triggers refs.Add() for this element. Why are we removing it afterwards? Looks like something went wrong in 324107b (and #1670) since a simple test shows zero counter after POPITEM and -1 after popping the only item left on the stack.

We're popping an item (array) off the stack, OK, it triggers refs.Remove() for
it. Then we're pushing an inner item to the stack, OK, it triggers refs.Add()
for this element. Why are we removing it afterwards? Looks like something went
wrong in 324107b (and #1670)
since a simple test shows zero counter after POPITEM and -1 after popping the
only item left on the stack.

Signed-off-by: Roman Khimov <[email protected]>
@roman-khimov roman-khimov added bug Something isn't working U1 Critically important to resolve quickly labels Nov 16, 2024
@roman-khimov roman-khimov added this to the v0.107.0 milestone Nov 16, 2024
Copy link

codecov bot commented Nov 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.06%. Comparing base (4a96bd1) to head (270f0d2).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3688      +/-   ##
==========================================
+ Coverage   83.00%   83.06%   +0.05%     
==========================================
  Files         334      334              
  Lines       46629    46628       -1     
==========================================
+ Hits        38706    38731      +25     
+ Misses       6348     6319      -29     
- Partials     1575     1578       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1459,7 +1459,6 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
case *stackitem.Struct:
item.Remove(index)
}
v.refs.Remove(elem)
Copy link
Member

Choose a reason for hiding this comment

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

It even had a separate designated review comment (324107b#r559602943), but I'm also not sure why this line was added.

@AnnaShaleva AnnaShaleva added the vm VM tasks/bugs/issues label Nov 18, 2024
@AnnaShaleva AnnaShaleva merged commit 990634a into master Nov 18, 2024
33 of 34 checks passed
@AnnaShaleva AnnaShaleva deleted the vm-fix-popitem-refcounting branch November 18, 2024 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working U1 Critically important to resolve quickly vm VM tasks/bugs/issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants