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): handle case of NumStmts = 0 when creating stacktraces #2813

Closed
wants to merge 5 commits into from

Conversation

thehowl
Copy link
Member

@thehowl thehowl commented Sep 18, 2024

without the patch, the test fails with this error:

--- FAIL: TestTestdata (1.97s)
    --- FAIL: TestTestdata/issue_outofgas_stacktrace (1.97s)
        testscript.go:558: # test for a bug involving printing stacktraces with missing statements;
            # when dumping out information for a test. (1.763s)
            > loadpkg gno.land/p/demo/avl
            "gno.land/p/demo/avl" package was added to genesis
            > gnoland start
            [stdout]
            node started successfully
            
            > ! gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/pkg1 -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1
            [stdout]
            TX HASH:    sMuFd6oGIxmMHuY1HLbVm6Mi30Nq6cF7mBC5Rt0chug=
            
            [stderr]
            Enter password.
            "gnokey" error: --= Error =--
            Data: runtime error: index out of range [-1]
            Msg Traces:
                0  /home/howl/oc/gno/tm2/pkg/crypto/keys/client/maketx.go:215 - deliver transaction failed: log:msg:0,success:false,log:--= Error =--
            Data: &errors.errorString{s:"runtime error: index out of range [-1]"}
            Msg Traces:
                0  /home/howl/oc/gno/gno.land/pkg/sdk/vm/keeper.go:386 - VM addpkg panic: runtime error: index out of range [-1]
            Machine:
                CheckTypes: false
                Op: [OpHalt OpPopResults]
                Values: (len: 1)
                      #0 (init.2 func()())
                Exprs:
                Stmts:
                Blocks:
                      @(50) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00a4c6b40,Source:func init.2() { for i<VPBlock(1,...,Parent:0xc00a17cd20)
             (s vals) @(50) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0060b0830,Source:func init.2() { for i<VPBlock(1,...,Parent:0xc0091d9230)
             (s typs) @(50) []
                      @(156) Block(ID:302e5163ca42d53def527ea18dfd0ca4ce3602ba:5,Addr:0xc00a17cd20,Source:file{ package hello; import strc...,Parent:0xc011300780)
                        strconv: (package(strconv strconv) package{})
                        avl: (package(avl gno.land/p/demo/avl) package{})
             (s vals) @(156) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0091d9230,Source:file{ package hello; import strc...,Parent:0xc0091d9530)
                        strconv: (package(strconv strconv) package{})
                        avl: (package(avl gno.land/p/demo/avl) package{})
             (s typs) @(156) [package{} package{}]
                Blocks (other):
                      #1 Block(ID:302e5163ca42d53def527ea18dfd0ca4ce3602ba:5,Addr:0xc00a17cd20,Source:file{ package hello; import strc...,Parent:0xc011300780)
                        strconv: (package(strconv strconv) package{})
                        avl: (package(avl gno.land/p/demo/avl) package{})
             (static) #1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0091d9230,Source:file{ package hello; import strc...,Parent:0xc0091d9530)
                        strconv: (package(strconv strconv) package{})
                        avl: (package(avl gno.land/p/demo/avl) package{})
                Frames:
                      #0 [FRAME FUNC:init.2 RECV:(undefined) (0 args) 2/0/0/0/2 LASTPKG:gno.land/r/pkg1 LASTRLM:Realm{Path:"gno.land/r/pkg1",Time:4003}#302E5163CA42D53DEF527EA18DFD0CA4CE3602BA]
                Realm:
                  gno.land/r/pkg1
                Exceptions:
            
            
            Stack Trace:
                0  /home/howl/oc/gno/tm2/pkg/errors/errors.go:20
                1  /home/howl/oc/gno/gno.land/pkg/sdk/vm/keeper.go:386
                2  /home/howl/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:770
                3  /home/howl/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:114
                4  /home/howl/oc/gno/gnovm/pkg/gnolang/machine.go:482
                5  /home/howl/oc/gno/gnovm/pkg/gnolang/machine.go:793
                6  /home/howl/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:770
                7  /home/howl/oc/gno/tm2/pkg/store/types/gas.go:97
                8  /home/howl/oc/gno/tm2/pkg/store/gas/store.go:46
                9  /home/howl/oc/gno/gnovm/pkg/gnolang/store.go:449
               10  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:747
               11  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:714
               12  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               13  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               14  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               15  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               16  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               17  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               18  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               19  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               20  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               21  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               22  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               23  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               24  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               25  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               26  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               27  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               28  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               29  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               30  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
               31  /home/howl/oc/gno/gnovm/pkg/gnolang/realm.go:703
            --= /Error =--
            ,events:[]
            --= /Error =--
            
            
            > stderr 'out of gas'
            FAIL: testdata/issue_outofgas_stacktrace.txtar:9: no match for `out of gas` found in stderr
            
FAIL
exit status 1
FAIL	github.com/gnolang/gno/gno.land/cmd/gnoland	2.001s

@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Sep 18, 2024
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@thehowl
Copy link
Member Author

thehowl commented Sep 18, 2024

cc @omarsy, if you can also take a look.

Copy link
Member

@omarsy omarsy left a comment

Choose a reason for hiding this comment

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

LGTM, but I'm wondering if is it necessary to include the realm's stack trace if we have an OutOfGasException?

@thehowl
Copy link
Member Author

thehowl commented Sep 20, 2024

LGTM, but I'm wondering if is it necessary to include the realm's stack trace if we have an OutOfGasException?

no, and it's not printed, but it was trying to create it anyway. i think the stacktrace is created, but eventually not used.

@thehowl
Copy link
Member Author

thehowl commented Oct 2, 2024

ping @deelawn

@Gno2D2
Copy link
Collaborator

Gno2D2 commented Dec 8, 2024

I'm a bot that assists the Gno Core team in maintaining this repository. My role is to ensure that contributors understand and follow our guidelines, helping to streamline the development process.

The following requirements must be fulfilled before a pull request can be merged.
Some requirement checks are automated and can be verified by the CI, while others need manual verification by a staff member.

These requirements are defined in this configuration file.

Automated Checks

🔴 Maintainers must be able to edit this pull request (more info)
🟢 The pull request head branch must be up-to-date with its base (more info)

Manual Checks

No manual checks match this pull request.

Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 On every pull request

Then

🔴 Requirement not satisfied
└── 🔴 Maintainer can modify this pull request

The pull request head branch must be up-to-date with its base (more info)

If

🟢 Condition met
└── 🟢 On every pull request

Then

🟢 Requirement satisfied
└── 🟢 Head branch (dev/morgan/stackframe-dump) is up to date with base (master): behind by 0 / ahead by 5

@thehowl
Copy link
Member Author

thehowl commented Dec 8, 2024

#3273 fixes this already

@thehowl thehowl closed this Dec 8, 2024
@thehowl thehowl deleted the dev/morgan/stackframe-dump branch December 8, 2024 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants