-
Notifications
You must be signed in to change notification settings - Fork 440
fix(gnovm): Add debug panic on Deepfill execution on constant type
#4891
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
base: master
Are you sure you want to change the base?
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Hi @Davphla . Can you fix the failed CI check for codecov? |
|
I've added minimal tests. Since added lines cover debug features and CI doesn't run in debug mode, further coverage isn't possible. |
thehowl
left a comment
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'd say just make them panic, in correct code this adds no overhead anyway (because DeepFill is often called through an interface, not lending itself to optimization). So might as well always panic.
| func (sv StringValue) DeepFill(store Store) Value { | ||
| if debug { | ||
| panic("StringValue.DeepFill should not be called - StringValue is only used for constant expressions") | ||
| } | ||
| return sv | ||
| } | ||
|
|
||
| func (biv BigintValue) DeepFill(store Store) Value { | ||
| if debug { | ||
| panic("BigintValue.DeepFill should not be called - BigintValue is only used for constant expressions") | ||
| } | ||
| return biv | ||
| } | ||
|
|
||
| func (bdv BigdecValue) DeepFill(store Store) Value { | ||
| if debug { | ||
| panic("BigdecValue.DeepFill should not be called - BigdecValue is only used for constant expressions") | ||
| } | ||
| return bdv | ||
| } |
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.
Why not just make these panic?
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 may cause involuntary informational panic, so I think it is safer to have a potential optimization then an accidental panic.
As well, it break tests 2b0ae1d
Failing test: https://github.com/gnolang/gno/actions/runs/19742512315/job/56569620776#step:5:10
Should the failing tests be considered in that PR?
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.
If it's not intended to happen, then it won't be "informational".
But by seeing the test results, it looks like either the behaviour is incorrect in the callers; or it would be incorrect to have a panic here
This reverts commit 2b0ae1d.
Fix: #4777
DeepFillreplace all references (RefValue) with concrete values loaded from storage.StringValue,BigintValue, andBigdecValueare value types that are never persisted as separate objects. They lackObjectInfo(refgnovm/pkg/gnolang/ownership.go:144) and are used for:ConstExprnodes during preprocessing)UntypedBigintTypeoperations ingnovm/pkg/gnolang/op_binary.go:693)Because these types are never persisted separately, they should never appear as
RefValuethat requireDeepFill.This is confirmed by their
VisitAssociatedimplementations ingnovm/pkg/gnolang/garbage_collector.go:378-386, which returnfalseindicating no associated values to visit during GC.This PR adds debug-mode assertions that panic when
DeepFillis called on these constant-only types, making it easier to catch incorrect handling of constant expressions during development.