Skip to content

fix(gnovm): make oversized slice make/append a recoverable panic#5723

Open
ltzmaxwell wants to merge 3 commits into
gnolang:masterfrom
ltzmaxwell:fix/make19
Open

fix(gnovm): make oversized slice make/append a recoverable panic#5723
ltzmaxwell wants to merge 3 commits into
gnolang:masterfrom
ltzmaxwell:fix/make19

Conversation

@ltzmaxwell

Copy link
Copy Markdown
Contributor

No description provided.

@Gno2D2

Gno2D2 commented May 26, 2026

Copy link
Copy Markdown
Collaborator

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
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:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: ltzmaxwell/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@davd-gzl davd-gzl self-requested a review May 28, 2026 23:20

@davd-gzl davd-gzl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes is good but there's missing similar cases, check davd-gzl@3b18b473e

git remote add davd-gzl https://github.com/davd-gzl/gno.git
git fetch davd-gzl
git cherry-pick 3b18b473e        # onto fix/make19
git push                          # updates his PR

@ltzmaxwell ltzmaxwell changed the title fix(gnovm): convert allocator size-overflow to recoverable panic fix(gnovm): make oversized slice make/append a recoverable panic Jun 3, 2026
make19 now triggers via bare oversized make; append/b were dead code.
@ltzmaxwell

Copy link
Copy Markdown
Contributor Author

@davd-gzl , thanks for the review. I dug into extending this and concluded it should stay scoped to slices:

  • Slices are the only user-reachable, slice-shaped overflow: make([]T, n) takes a cheap user-controlled length, and allocArrayItem × n overflows int64 before any memory is touched. That's this PR, using Go's own makeslice: len out of range message. append shares the same allocators, so it's covered.
  • Maps have the same shape but Go's makemap clamps an oversized hint instead of panicking — so the right fix is to clamp, not raise a recoverable panic. Handling that separately: WIP fix(gnovm): clamp bogus make(map, n) hint #5770.
  • String / struct fields / block: not equivalent. Their counts are bounded by source (field/name counts), so they can't reach the overflow threshold from cheap input. And if one somehow did, it's an internal allocation invariant, not a user make error — an unrecoverable panic is the correct outcome there, not a recoverable *Exception().

Happy to discuss if I've missed a case.

@thehowl thehowl added the a/vm GnoVM, Security, Runtime team label Jun 11, 2026

@davd-gzl davd-gzl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Agreed I overstated it, LGTM!

}

// mustFit returns v from a preceding overflow.Add/Mul, or raises a
// recoverable Gno *Exception (the same "makeslice: len out of range" runtime

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this comment can be simplified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a/vm GnoVM, Security, Runtime team 📦 🤖 gnovm Issues or PRs gnovm related

Projects

Development

Successfully merging this pull request may close these issues.

4 participants