Cosmos-sdk: error in gaiacli query account

Created on 26 Jan 2019  Â·  8Comments  Â·  Source: cosmos/cosmos-sdk

Summary of Bug

[cosmos@sunny ~]$ gaiacli query account cosmos1jxv0u20scum4trha72c7ltfgfqef6nscj25050 --chain-id=gaia-10k --trust-node=false
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xad97ff]

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/x/auth.BaseAccount.String(0xc001399c00, 0x14, 0x14, 0xc00139e450, 0x2, 0x2, 0x0, 0x0, 0x1de, 0x0, ...)
        /home/cosmos/go/src/github.com/cosmos/cosmos-sdk/x/auth/account.go:91 +0x3f
github.com/cosmos/cosmos-sdk/client/context.CLIContext.PrintOutput(0xc000199500, 0xc0001a34f0, 0x135edc0, 0xc0008e5880, 0x1348780, 0xc0000a6008, 0xeba228, 0x4, 0x0, 0xec9e08, ...)
        /home/cosmos/go/src/github.com/cosmos/cosmos-sdk/client/context/context.go:266 +0x253
github.com/cosmos/cosmos-sdk/x/auth/client/cli.GetAccountCmd.func1(0xc0001a0c80, 0xc000892de0, 0x1, 0x3, 0x0, 0x0)
        /home/cosmos/go/src/github.com/cosmos/cosmos-sdk/x/auth/client/cli/account.go:38 +0x320
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).execute(0xc0001a0c80, 0xc000892d20, 0x3, 0x3, 0xc0001a0c80, 0xc000892d20)
        /home/cosmos/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:762 +0x473
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000146280, 0x24, 0xc000996808, 0xed298b)
        /home/cosmos/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:852 +0x2fd
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).Execute(0xc000146280, 0x1, 0xc00000eda8)
        /home/cosmos/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:800 +0x2b
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli.Executor.Execute(0xc000146280, 0x127e2b0, 0x2, 0xc0008eda00)
        /home/cosmos/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli/setup.go:89 +0x4e
main.main()
        /home/cosmos/go/src/github.com/cosmos/cosmos-sdk/cmd/gaia/cmd/gaiacli/main.go:102 +0x58c
[cosmos@sunny ~]$ gaiacli query account cosmos1umaajfgap5ef6yxvk5706kwk8j08l7wha3e6zh --chain-id=gaia-10k --trust-node=false
Account cosmos1umaajfgap5ef6yxvk5706kwk8j08l7wha3e6zh:
  Coins:         10000000000photinos
  PubKey:        E6FBD9251D0D329D10CCB53CFD59D63C9E7FF9D7
  AccountNumber: 753
  Sequence:      1

Steps to Reproduce


My address(cosmos1jxv0u20scum4trha72c7ltfgfqef6nscj25050) was defined in genesis.json of gaia-10k and my gentx.json did not accept.

This address(cosmos1umaajfgap5ef6yxvk5706kwk8j08l7wha3e6zh) finished both of them work properly.

This error message should be more friendly


For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned
bug needs-more-info

All 8 comments

I saw exactly the same error.
I was able to create a validator using tx staking create-validator... and after creating the validator, gaiacli query account... worked fine.

Can confirm. Here is the log from querying my account before doing any tx:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xadd4cf]

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/x/auth.BaseAccount.String(0xc000a47000, 0x14, 0x14, 0xc000a37a10, 0x2, 0x2, 0x0, 0x0, 0x3a2, 0x0, ...)
        /home/ubuntu/go/src/github.com/cosmos/cosmos-sdk/x/auth/account.go:91 +0x3f
github.com/cosmos/cosmos-sdk/client/context.CLIContext.PrintOutput(0xc0001ba230, 0xc000ac91a0, 0x1363e60, 0xc000a93e40, 0x134d820, 0xc0000a8008, 0xebf188, 0x4, 0x0, 0xeced6e, ...)
        /home/ubuntu/go/src/github.com/cosmos/cosmos-sdk/client/context/context.go:266 +0x253
github.com/cosmos/cosmos-sdk/x/auth/client/cli.GetAccountCmd.func1(0xc0001a6c80, 0xc000a93840, 0x1, 0x2, 0x0, 0x0)
        /home/ubuntu/go/src/github.com/cosmos/cosmos-sdk/x/auth/client/cli/account.go:38 +0x320
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).execute(0xc0001a6c80, 0xc000a93800, 0x2, 0x2, 0xc0001a6c80, 0xc000a93800)
        /home/ubuntu/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:762 +0x473
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc00014a280, 0x24, 0xc000a1f628, 0xed790a)
        /home/ubuntu/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:852 +0x2fd
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).Execute(0xc00014a280, 0x1, 0xc00000eae0)
        /home/ubuntu/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:800 +0x2b
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli.Executor.Execute(0xc00014a280, 0x1283280, 0x2, 0xc00096be40)
        /home/ubuntu/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli/setup.go:89 +0x4e
main.main()
        /home/ubuntu/go/src/github.com/cosmos/cosmos-sdk/cmd/gaia/cmd/gaiacli/main.go:102 +0x58c

After the create-validator tx from that account, the query account command worked just fine.

I reproduced using a new account and sending some coins back and forth.

Create a new keys using gaiacli. Send it something:

mattharrop@figment-gaia9k:~$ /opt/go/bin/gaiacli tx send --amount=100000photinos --from=gos --to=cosmos1ft55arkmnfxyn7mpdswy2h0cz8sg4zqffwe2x4 --chain-id=gaia-10k --gas-prices=0.01photinos --gas=27000
Password to sign with 'gos':
Committed at block 9145 (tx hash: 8FD14487EC41366077F33F92E26E4137B40672B27F4B5BFA999C271C37354C79, response: {Code:0 Data:[] Log:Msg 0:  Info: GasWanted:27000 GasUsed:24810 Tags:[{Key:[97 99 116 105 111 110] Value:[115 101 110 100] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[115 101 110 100 101 114] Value:[99 111 115 109 111 115 49 50 55 108 112 120 104 50 55 102 50 106 100 54 56 52 101 121 120 57 116 122 122 99 100 107 48 54 114 57 107 110 99 115 113 113 118 103 103] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[114 101 99 105 112 105 101 110 116] Value:[99 111 115 109 111 115 49 102 116 53 53 97 114 107 109 110 102 120 121 110 55 109 112 100 115 119 121 50 104 48 99 122 56 115 103 52 122 113 102 102 119 101 50 120 52] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0}] Codespace: XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0})

Query the new account will cause the panic:

mattharrop@figment-gaia9k:~$ /opt/go/bin/gaiacli query account cosmos1ft55arkmnfxyn7mpdswy2h0cz8sg4zqffwe2x4 --chain-id=gaia-10k
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xadd4cf]

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/x/auth.BaseAccount.String(0xc000aeb8e0, 0x14, 0x14, 0xc000aee6a0, 0x1, 0x1, 0x0, 0x0, 0x3de, 0x0, ...)
    /home/mattharrop/go/src/github.com/cosmos/cosmos-sdk/x/auth/account.go:91 +0x3f
github.com/cosmos/cosmos-sdk/client/context.CLIContext.PrintOutput(0xc0001a1ab0, 0xc00009f1d0, 0x13632a0, 0xc00092f060, 0x134cc60, 0xc0000ae008, 0xebe8a8, 0x4, 0x0, 0xece488, ...)
    /home/mattharrop/go/src/github.com/cosmos/cosmos-sdk/client/context/context.go:266 +0x253
github.com/cosmos/cosmos-sdk/x/auth/client/cli.GetAccountCmd.func1(0xc0001a8c80, 0xc00094c1e0, 0x1, 0x2, 0x0, 0x0)
    /home/mattharrop/go/src/github.com/cosmos/cosmos-sdk/x/auth/client/cli/account.go:38 +0x320
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).execute(0xc0001a8c80, 0xc00094c1a0, 0x2, 0x2, 0xc0001a8c80, 0xc00094c1a0)
    /home/mattharrop/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:762 +0x473
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc0000dd400, 0x24, 0xc00003b6c8, 0xed700b)
    /home/mattharrop/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:852 +0x2fd
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).Execute(0xc0000dd400, 0x1, 0xc0001dcbd0)
    /home/mattharrop/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:800 +0x2b
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli.Executor.Execute(0xc0000dd400, 0x1282980, 0x2, 0xc00098b040)
    /home/mattharrop/go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli/setup.go:89 +0x4e
main.main()
    /home/mattharrop/go/src/github.com/cosmos/cosmos-sdk/cmd/gaia/cmd/gaiacli/main.go:102 +0x58c

Send something out from the new account:

mattharrop@figment-gaia9k:~$ /opt/go/bin/gaiacli tx send --amount=1000photinos --from=new --to=cosmos127lpxh27f2jd684eyx9tzzcdk06r9kncsqqvgg --chain-id=gaia-10k --gas-prices=0.01photinos --gas=27000
Password to sign with 'new':
Committed at block 9162 (tx hash: 7A02F13D1329614CE4C1E1339CDDAD42AAD10128A14B9F5FD5CD5B147122951D, response: {Code:0 Data:[] Log:Msg 0:  Info: GasWanted:27000 GasUsed:25554 Tags:[{Key:[97 99 116 105 111 110] Value:[115 101 110 100] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[115 101 110 100 101 114] Value:[99 111 115 109 111 115 49 102 116 53 53 97 114 107 109 110 102 120 121 110 55 109 112 100 115 119 121 50 104 48 99 122 56 115 103 52 122 113 102 102 119 101 50 120 52] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[114 101 99 105 112 105 101 110 116] Value:[99 111 115 109 111 115 49 50 55 108 112 120 104 50 55 102 50 106 100 54 56 52 101 121 120 57 116 122 122 99 100 107 48 54 114 57 107 110 99 115 113 113 118 103 103] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0}] Codespace: XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0})

Query the account, now it works fine:

mattharrop@figment-gaia9k:~$ /opt/go/bin/gaiacli query account cosmos1ft55arkmnfxyn7mpdswy2h0cz8sg4zqffwe2x4 --chain-id=gaia-10k
Account cosmos1ft55arkmnfxyn7mpdswy2h0cz8sg4zqffwe2x4:
  Coins:         98858photinos
  PubKey:        4AE94E8EDB9A4C49FB616C1C455DF811E08A8809
  AccountNumber: 990
  Sequence:      1

What version are you running @liangping? This should've been fixed in https://github.com/cosmos/cosmos-sdk/pull/3365/files#diff-21f3e96ec36110c056077521103f82d3 which was already merged.

@jackzampolin this is because the pubkey was added to the stringer output. Not all accounts will have a pubkey when querying fyi. So you'll be calling Address on a nil value. The pubkey is set in the ante handler when the account in question is handled in a tx.


Looks like I missed the stringer fix for BaseAccount. We just need to remove the pubkey field for BaseAccount#String.

cosmos-sdk: 0.30.0-0-ge003c5e

I'm running cosmos-sdk: 0.30.0-2-g5985bbd4 and also get the error (see comment above)

~$ /opt/go/bin/gaiacli version
cosmos-sdk: 0.30.0-0-ge003c5eb
git commit: e003c5ebe02bed51056e46d5ff1a232e2bd00dda
vendor hash: 6f140888964031e5b09a3c586bdb151a2f730b74
go version go1.11.5 linux/amd64

Correct, pubkey needs to be removed from BaseAccount#String.

Was this page helpful?
0 / 5 - 0 ratings