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(gnovm): Resolve RefValues before using as Objects #2454

Merged
merged 3 commits into from
Jul 2, 2024

Conversation

deelawn
Copy link
Contributor

@deelawn deelawn commented Jun 27, 2024

Closes #2449.

I believe the bug was introduced by #2255. Previously, if the type of tv.V in GetFirstObject was a PointerValue, it the Base would have been nil in the scenario producing this bug. Now that Base can never be nil for a PointerValue, the nil base check has been removed. We do however need to account for a new scenario where the Base is a RefValue, a type that does implement the Object interface. In the case where the base is a RefValue, first resolve it by calling store.GetObject.

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Jun 27, 2024
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 54.80%. Comparing base (3901e7e) to head (26aeaf6).
Report is 4 commits behind head on master.

Files Patch % Lines
gnovm/pkg/gnolang/values.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2454      +/-   ##
==========================================
+ Coverage   54.68%   54.80%   +0.12%     
==========================================
  Files         583      583              
  Lines       78503    79124     +621     
==========================================
+ Hits        42928    43364     +436     
- Misses      32368    32486     +118     
- Partials     3207     3274      +67     
Flag Coverage Δ
contribs/gnodev 23.81% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (-0.86%) ⬇️
contribs/gnokeykc 0.00% <ø> (ø)
contribs/gnomd 0.00% <ø> (ø)
gno.land 62.54% <ø> (ø)
gnovm 59.96% <50.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

@mvertes mvertes left a comment

Choose a reason for hiding this comment

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

The test could be improved to validate content, otherwise LGTM.

Copy link
Contributor

@piux2 piux2 left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks

@deelawn deelawn merged commit 3b42391 into master Jul 2, 2024
86 of 87 checks passed
@deelawn deelawn deleted the bug/ptr-ref-value branch July 2, 2024 17:30
gfanton pushed a commit to gfanton/gno that referenced this pull request Jul 23, 2024
Closes gnolang#2449.

I believe the bug was introduced by gnolang#2255. Previously, if the type of
`tv.V` in `GetFirstObject` was a `PointerValue`, it the `Base` would
have been nil in the scenario producing this bug. Now that `Base` can
never be nil for a `PointerValue`, the nil base check has been removed.
We do however need to account for a new scenario where the `Base` is a
`RefValue`, a type that does implement the `Object` interface. In the
case where the base is a `RefValue`, first resolve it by calling
`store.GetObject`.

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [x] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[GnoVM] Missing method DecRefCount when deleting element in pointer slice
5 participants