Skip to content

Commit

Permalink
fix(gnovm): make Stacktrace correctly handle panics with `len(Stmts…
Browse files Browse the repository at this point in the history
…) == 0` (#3273)

While finalizing the realm, all statements in the machine have been
popped out. A necessary check must be performed during stack trace
handling.
<!-- please provide a detailed description of the changes made in this
pull request. -->

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

- [ ] 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
</details>

Co-authored-by: Petar Dambovaliev <[email protected]>
  • Loading branch information
ltzmaxwell and petar-dambovaliev authored Dec 7, 2024
1 parent 53cee96 commit 66c2eb6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func destar(x Expr) Expr {
// Stacktrace returns the stack trace of the machine.
// It collects the executions and frames from the machine's frames and statements.
func (m *Machine) Stacktrace() (stacktrace Stacktrace) {
if len(m.Frames) == 0 {
if len(m.Frames) == 0 || len(m.Stmts) == 0 {
return
}

Expand Down

0 comments on commit 66c2eb6

Please sign in to comment.