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

Open
wants to merge 3 commits into
base: master
Choose a base branch
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 ✅

Project coverage is 60.89%. Comparing base (09b6241) to head (b5ae57d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2813      +/-   ##
==========================================
- Coverage   60.90%   60.89%   -0.02%     
==========================================
  Files         564      564              
  Lines       75273    75278       +5     
==========================================
- Hits        45846    45840       -6     
- Misses      26055    26061       +6     
- Partials     3372     3377       +5     
Flag Coverage Δ
contribs/gnodev 61.46% <ø> (ø)
contribs/gnofaucet 15.31% <ø> (+0.85%) ⬆️
gno.land 67.17% <ø> (ø)
gnovm 65.78% <100.00%> (+<0.01%) ⬆️
misc/genstd 80.54% <ø> (ø)
misc/logos 20.23% <ø> (+0.35%) ⬆️
tm2 61.92% <ø> (-0.12%) ⬇️

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.

@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

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: No status
Status: In Review
Development

Successfully merging this pull request may close these issues.

2 participants