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

r/gnoland/faucet.Render panics #621

Closed
tbruyelle opened this issue Mar 20, 2023 · 0 comments · Fixed by #628
Closed

r/gnoland/faucet.Render panics #621

tbruyelle opened this issue Mar 20, 2023 · 0 comments · Fixed by #628

Comments

@tbruyelle
Copy link
Contributor

Description

Under the minimal genesis gnoland blockchain, it's not possible to render the faucet contract :

image

Your environment

  • OS and version : linux 6.1.18
  • version of gno : 66d5dcc

Steps to reproduce

  • Tell us how to reproduce this issue

    call the render of the r/gnoland/faucet contract.
  • Where the issue is, if you know

    Assumption: The Render method loops on gControllers using gControllerSize, but without checking if gControllers.Size() is greater or equal than gControllerSize.

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

Logs

website binary log:

Log: --= Error =--
Data: &errors.errorString{s:"interface conversion: gnolang.Value is nil, not gnolang.PointerValue"}
Msg Traces:
    0  /home/tom/src/gno/pkgs/sdk/vm/keeper.go:430 - VM query eval string panic: interface conversion: gnolang.Value is nil, not gnolang.PointerValue
Machine:
    CheckTypes: false
	Op: [OpHalt OpBody OpForLoop OpDefine OpBody OpReturn OpBody OpPopBlock OpIfCond OpPrecall OpEql OpEval]
	Values: (len: 5)
          #4 (nil *gno.land/p/demo/avl.Node)
          #3 (typeval{bool} type{})
          #2 (<*gno.land/p/demo/avl.Node>.GetByIndex(node *gno.land/p/demo/avl.Node,index int)(key string,value interface{}) func(index int)(key string,value interface{}))
          #1 (<*gno.land/p/demo/avl.Tree>.GetByIndex(tree *gno.land/p/demo/avl.Tree,index int)(key string,value interface{}) func(index int)(key string,value interface{}))
          #0 (Render func(path string)( string))
	Exprs:
          #2 (const (0 int8))
          #1 node<VPBlock(2,0)>.height == (const (0 int8))
          #0 (const-type bool)(node<VPBlock(2,0)>.height == (const (0 int8)))
	Stmts:
          #3 bodyStmt[0/0/1]=(end)
          #2 bodyStmt[0/0/1]=(end)
          #1 bodyStmt[0/0/1]=output<VPBlock(2,4)> += ufmt<VPBlock(3,3)>.Sprintf((const ("%!s(MISSING)  " string)), v<VPBlock(1,1)>.(std<VPBlock(3,1)>.Address))*
          #0 bodyStmt[0/0/10]=output<VPBlock(1,4)> += (const ("\n\n" string))*
	Blocks:
          @(1) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0018dc3c0,Source:if (const-type bool)(node<VPBloc...,Parent:0xc0018dc1e0)
 (s vals) @(1) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0001ed020,Source:if (const-type bool)(node<VPBloc...,Parent:0xc0001e8420)
 (s typs) @(1) []
          @(2) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0018dc1e0,Source:func (node *(Node<VPBlock(2,0)>)...,Parent:0xc0017dbc20)
            node: (nil *gno.land/p/demo/avl.Node)
            index: (0 int)
            key: ( string)
            value: (undefined)
 (s vals) @(2) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0001e8420,Source:func (node *(Node<VPBlock(2,0)>)...,Parent:0xc00042ede0)
            node: (nil *gno.land/p/demo/avl.Node)
            index: (0 int)
            key: ( string)
            value: (undefined)
 (s typs) @(2) [*gno.land/p/demo/avl.Node int string interface{}]
          @(3) Block(ID:26a90809de387e567a70972c32a4cc9e8d44e55f:3,Addr:0xc0017dbc20,Source:ref(gno.land/p/demo/avl/node.gno...,Parent:%!!(MISSING)p(gnolang.RefValue={{{[38 169 8 9 222 56 126 86 122 112 151 44 50 164 204 158 141 68 229 95]} 2} true  {[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]}}))
            (RefNode names not shown)
 (s vals) @(3) Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00042ede0,Source:file{ package avl; type Node (co...,Parent:0xc0004bf620)
 (s typs) @(3) []
            (block ref 26a90809de387e567a70972c32a4cc9e8d44e55f:2)
	Blocks (other):
          #4 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0018dc1e0,Source:func (node *(Node<VPBlock(2,0)>)...,Parent:0xc0017dbc20)
            node: (nil *gno.land/p/demo/avl.Node)
            index: (0 int)
            key: ( string)
            value: (undefined)
 (static) #4 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0001e8420,Source:func (node *(Node<VPBlock(2,0)>)...,Parent:0xc00042ede0)
            node: (nil *gno.land/p/demo/avl.Node)
            index: (0 int)
            key: ( string)
            value: (undefined)
          #3 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0018dc000,Source:func (tree *(Tree<VPBlock(2,1)>)...,Parent:0xc0017dbe00)
            tree: (&0xc00d280e70.(*gno.land/p/demo/avl.Tree) *gno.land/p/demo/avl.Tree)
            index: (0 int)
            key: ( string)
            value: (undefined)
 (static) #3 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00027a820,Source:func (tree *(Tree<VPBlock(2,1)>)...,Parent:0xc0002798e0)
            tree: (nil *gno.land/p/demo/avl.Tree)
            index: (0 int)
            key: ( string)
            value: (undefined)
          #2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc0017db860,Source:for i<VPBlock(1,0)> := (const (0...,Parent:0xc001a85c20)
            i: (0 int)
            v: (undefined)
 (static) #2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc001b68020,Source:for i<VPBlock(1,0)> := (const (0...,Parent:0xc00a81ec20)
            i: (0 int)
            v: (undefined)
          #1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc001a85c20,Source:func Render(path (const-type str...,Parent:0xc001a843c0)
            path: ("" string)
            .res_0: ( string)
            banker: (struct{(gonative{{0xc0045927e0 g1ttrq7mp4zy6dssnmgyyktnn4hcj3ys8xhju0n7}} gonative{stdlibs.RealmSendBanker})} std.bankAdapter)
            balance: (nil std.Coins)
            output: ("# Community Faucet.\n\nStatus: active.\nBalance: .\nTotal transfers:  (in 0 times).\n\nPackage address: g1ttrq7mp4zy6dssnmgyyktnn4hcj3ys8xhju0n7\n\nAdmin: g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5\n\n Controllers:\n\n " string)
 (static) #1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0xc00a81ec20,Source:func Render(path (const-type str...,Parent:0xc0062e78e0)
            path: ( string)
            .res_0: ( string)
            banker: (undefined)
            balance: (nil std.Coins)
            output: ( string)
	Frames:
          #3 [FRAME FUNC:GetByIndex RECV:(nil *gno.land/p/demo/avl.Node) (1 args) 6/2/0/3/4 LASTPKG:gno.land/p/demo/avl LASTRLM:Realm{Path:"gno.land/r/gnoland/faucet",Time:6}#803C8BAA04ABA3C2168C8DE81613049DF3D13D96]
          #2 [FRAME FUNC:GetByIndex RECV:(&0xc00d280e70.(*gno.land/p/demo/avl.Tree) *gno.land/p/demo/avl.Tree) (1 args) 4/1/0/2/3 LASTPKG:gno.land/r/gnoland/faucet LASTRLM:Realm{Path:"gno.land/r/gnoland/faucet",Time:6}#803C8BAA04ABA3C2168C8DE81613049DF3D13D96]
          #1 [FRAME LABEL:  2/1/0/1/2]
          #0 [FRAME FUNC:Render RECV:(undefined) (1 args) 1/0/0/0/1 LASTPKG:gno.land/r/gnoland/faucet LASTRLM:Realm{Path:"gno.land/r/gnoland/faucet",Time:6}#803C8BAA04ABA3C2168C8DE81613049DF3D13D96]
	Realm:
	  gno.land/r/gnoland/faucet
	Exception:
	  <nil>
	  undefined

Stack Trace:
    0  /home/tom/src/gno/pkgs/errors/errors.go:20
    1  /home/tom/src/gno/pkgs/sdk/vm/keeper.go:430
    2  /usr/lib/go/src/runtime/panic.go:884
    3  /usr/lib/go/src/runtime/iface.go:262
    4  /usr/lib/go/src/runtime/iface.go:272
    5  /home/tom/src/gno/pkgs/gnolang/values.go:1604
    6  /home/tom/src/gno/pkgs/gnolang/op_expressions.go:81
    7  /home/tom/src/gno/pkgs/gnolang/machine.go:1119
    8  /home/tom/src/gno/pkgs/gnolang/machine.go:571
    9  /home/tom/src/gno/pkgs/sdk/vm/keeper.go:436
   10  /home/tom/src/gno/pkgs/sdk/vm/handler.go:139
   11  /home/tom/src/gno/pkgs/sdk/vm/handler.go:100
   12  /home/tom/src/gno/pkgs/sdk/baseapp.go:496
   13  /home/tom/src/gno/pkgs/sdk/baseapp.go:393
   14  /home/tom/src/gno/pkgs/bft/abci/client/local_client.go:180
   15  /home/tom/src/gno/pkgs/bft/proxy/app_conn.go:143
   16  /home/tom/src/gno/pkgs/bft/rpc/core/abci.go:59
   17  /usr/lib/go/src/reflect/value.go:589
   18  /usr/lib/go/src/reflect/value.go:370
   19  /home/tom/src/gno/pkgs/bft/rpc/lib/server/handlers.go:158
   20  /home/tom/src/gno/pkgs/bft/rpc/lib/server/handlers.go:183
   21  /usr/lib/go/src/net/http/server.go:2123
   22  /usr/lib/go/src/net/http/server.go:2501
   23  /usr/lib/go/src/net/http/request.go:1142
   24  /home/tom/src/gno/pkgs/bft/rpc/lib/server/http_server.go:181
   25  /usr/lib/go/src/net/http/server.go:2123
   26  /usr/lib/go/src/net/http/server.go:2937
   27  /usr/lib/go/src/net/http/server.go:1996
   28  /usr/lib/go/src/runtime/asm_amd64.s:1599
--= /Error =--
@tbruyelle tbruyelle changed the title r/gnoland/faucet Render panics r/gnoland/faucet.Render panics Mar 20, 2023
tbruyelle added a commit to tbruyelle/gno that referenced this issue Mar 21, 2023
Fix gnolang#621

`Render` prints the controllers in a loop but relies on
`gControllersSize` rather than `gControllers.Size()` to determine the
number of controllers. The fix simply replaces `gControllersSize` by
`gControllers.Size()`.

Fix gnolang#627

filetest `Output:` directive doesn't work when the output contains
multiple consecutive empty lines, because the method used to collect
those comments truncate them (see issue and `ast.CommentGroup.Text()`).
The fix replaces this method by a custom one that doesn't truncate.
tbruyelle added a commit to tbruyelle/gno that referenced this issue Apr 3, 2023
Fix gnolang#621

`Render` prints the controllers in a loop but relies on
`gControllersSize` rather than `gControllers.Size()` to determine the
number of controllers. The fix simply replaces `gControllersSize` by
`gControllers.Size()`.

Fix gnolang#627

filetest `Output:` directive doesn't work when the output contains
multiple consecutive empty lines, because the method used to collect
those comments truncate them (see issue and `ast.CommentGroup.Text()`).
The fix replaces this method by a custom one that doesn't truncate.
@moul moul closed this as completed in #628 Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

1 participant