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: []byte("xxx") should not be treated as const #1597

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

ltzmaxwell
Copy link
Contributor

@ltzmaxwell ltzmaxwell commented Jan 29, 2024

this is a fix to #1570 .

The underlying issue in #1570 stems from how []byte("xxx") is handled: it's treated as a constant, yet its value can still be altered. This mutability leads to unintended persistence of its state across loop iterations.

The proposed resolution involves modifying the preprocessing stage to avoid converting an untyped string directly into a []byte type.

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

codecov bot commented Jan 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b619351) 55.80% compared to head (fbce7dc) 56.17%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1597      +/-   ##
==========================================
+ Coverage   55.80%   56.17%   +0.37%     
==========================================
  Files         436      436              
  Lines       66168    66549     +381     
==========================================
+ Hits        36922    37382     +460     
+ Misses      26356    26247     -109     
- Partials     2890     2920      +30     
Flag Coverage Δ
go-1.21.x ∅ <ø> (∅)
misc ∅ <ø> (∅)
misc-_test.genstd ∅ <ø> (∅)

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

@deelawn deelawn left a comment

Choose a reason for hiding this comment

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

Nice job! Looks good to me

@thehowl thehowl linked an issue Feb 14, 2024 that may be closed by this pull request
@thehowl thehowl merged commit 6fb3317 into gnolang:master Feb 14, 2024
192 checks passed
leohhhn pushed a commit to leohhhn/gno that referenced this pull request Feb 29, 2024
…lang#1597)

this is a fix to gnolang#1570 .

The underlying issue in gnolang#1570 stems from how []byte("xxx") is handled:
it's treated as a constant, yet its value can still be altered. This
mutability leads to unintended persistence of its state across loop
iterations.

The proposed resolution involves modifying the preprocessing stage to
avoid converting an untyped string directly into a []byte type.
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
Status: No status
Archived in project
Development

Successfully merging this pull request may close these issues.

[]byte("string") created in for loops are "persisted" on iteration
4 participants