koinos / koinos-cli

A command line utility used for key management and to interact with the Koinos blockchain.
Other
9 stars 7 forks source link

[BUG]: SIGSEGV when disconnected #104

Closed mvandeberg closed 2 years ago

mvandeberg commented 2 years ago

Is there an existing issue for this?

Current behavior

The CLI seg faults when attempting to upload a contract when disconnected from an endpoint. (This may happen on other commands, not sure)

cli segv

Expected behavior

The CLI should not die, but instead return a human readable error message explaining how to fix the problem (e.g. connect to an endpoint).

Steps to reproduce

  1. Open a wallet
  2. Attempt to upload a contract

Environment

- OS: Mac OS

Anything else?

No response

sgerbino commented 2 years ago

Copying this from a user on Discord:

I'm trying to register as a block producer, and on the first step, register pob ADDRESS I'm getting a runtime error:

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

goroutine 1 [running]:
github.com/koinos/koinos-util-golang/rpc.(*KoinosRPCClient).Call(0x0, {0x94ec13, 0x25}, {0xb017a0, 0xc0000300c0}, {0xb017c0, 0xc0002644b0})
        /home/nathan/go/pkg/mod/github.com/koinos/koinos-util-golang@v0.0.0-20220708183907-67c029f58812/rpc/koinos_rpc_client.go:66 +0xe2
github.com/koinos/koinos-util-golang/rpc.(*KoinosRPCClient).GetContractMeta(0xc0000dc810, {0xc00002c1c0, 0x19, 0x19})
        /home/nathan/go/pkg/mod/github.com/koinos/koinos-util-golang@v0.0.0-20220708183907-67c029f58812/rpc/koinos_rpc_client.go:190 +0xe5
github.com/koinos/koinos-cli/internal/cli.(*RegisterCommand).Execute(0xc000264480, {0x0, 0x300000000}, 0xc0000bd700)
        /home/nathan/src/koinos-cli/internal/cli/contract_commands.go:67 +0x497
github.com/koinos/koinos-cli/internal/cli.(*ParseResults).Interpret(0xc00000e1c8, 0xc00002a240)
        /home/nathan/src/koinos-cli/internal/cli/interpreter.go:311 +0xf3
github.com/koinos/koinos-cli/internal/cli.ParseAndInterpret(0xbf00000005, 0x7f1c030000008a3b, {0xc00002a240, 0x16170f1200})
        /home/nathan/src/koinos-cli/internal/cli/interpreter.go:373 +0x3d6
github.com/koinos/koinos-cli/cmd/cli/interactive.(*KoinosPrompt).executor(0x50fbca, {0xc00002a240, 0xc000130200})
        /home/nathan/src/koinos-cli/cmd/cli/interactive/interactive.go:117 +0x31
github.com/koinos/go-prompt.(*Prompt).Run(0xc0001302d0)
        /home/nathan/go/pkg/mod/github.com/koinos/go-prompt@v0.0.0-20220818181004-5b1028a45a2f/prompt.go:84 +0x765
github.com/koinos/koinos-cli/cmd/cli/interactive.(*KoinosPrompt).Run(0xc00026bc20)
        /home/nathan/src/koinos-cli/cmd/cli/interactive/interactive.go:125 +0xb4
main.main()
        /home/nathan/src/koinos-cli/cmd/cli/main.go:92 +0x42a
sgerbino commented 2 years ago

I was able to reproduce this like so:

Koinos CLI v0.4.0
Type "list" for a list of commands, "help <command>" for help on a specific command.
🚫 🔐 > upload wasm/calc.wasm abi/calc.abi
no open wallet: cannot upload contract

🚫 🔐 > open wallets/calc.wallet calc
Opened wallet: wallets/calc.wallet

🚫 🔓 > upload wasm/calc.wasm abi/calc.abi
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x443f822]

goroutine 1 [running]:
github.com/koinos/koinos-util-golang/rpc.(*KoinosRPCClient).Call(0x0, {0x45687a6, 0x17}, {0x47454e0?, 0xc000032780?}, {0x4745500, 0xc000032a00})
    /Users/sgerbino/go/pkg/mod/github.com/koinos/koinos-util-golang@v0.0.0-20220708183907-67c029f58812/rpc/koinos_rpc_client.go:66 +0xe2
github.com/koinos/koinos-util-golang/rpc.(*KoinosRPCClient).GetAccountNonce(0x44d2480?, {0xc000146580, 0x19, 0x19})
    /Users/sgerbino/go/pkg/mod/github.com/koinos/koinos-util-golang@v0.0.0-20220708183907-67c029f58812/rpc/koinos_rpc_client.go:168 +0xd8
github.com/koinos/koinos-cli/internal/cli.(*ExecutionEnvironment).GetNonce(0xc000032fc0)
    /Users/sgerbino/Projects/koinos-cli/internal/cli/interpreter.go:113 +0x175
github.com/koinos/koinos-cli/internal/cli.(*ExecutionEnvironment).GetSubmissionParams(0xc000473a00?)
    /Users/sgerbino/Projects/koinos-cli/internal/cli/interpreter.go:171 +0x1e
github.com/koinos/koinos-cli/internal/cli.(*ExecutionEnvironment).SubmitTransaction(0xc000032fc0, 0xc00000e2b8, {0xc0000100d0, 0x1, 0x1})
    /Users/sgerbino/Projects/koinos-cli/internal/cli/interpreter.go:153 +0x45
github.com/koinos/koinos-cli/internal/cli.(*UploadContractCommand).Execute(0xc00017e3f0, {0x0?, 0x0?}, 0xc000032fc0)
    /Users/sgerbino/Projects/koinos-cli/internal/cli/commands.go:456 +0x133f
github.com/koinos/koinos-cli/internal/cli.(*ParseResults).Interpret(0xc00000e540, 0xc0003800f0?)
    /Users/sgerbino/Projects/koinos-cli/internal/cli/interpreter.go:311 +0xf3
github.com/koinos/koinos-cli/internal/cli.ParseAndInterpret(0x1215177fffff04?, 0xf161311191a1c03?, {0xc0003800f0?, 0x9600?})
    /Users/sgerbino/Projects/koinos-cli/internal/cli/interpreter.go:373 +0x3d6
github.com/koinos/koinos-cli/cmd/cli/interactive.(*KoinosPrompt).executor(0x411090a?, {0xc0003800f0?, 0x4a69700?})
    /Users/sgerbino/Projects/koinos-cli/cmd/cli/interactive/interactive.go:117 +0x31
github.com/koinos/go-prompt.(*Prompt).Run(0xc0001963f0)
    /Users/sgerbino/go/pkg/mod/github.com/koinos/go-prompt@v0.0.0-20220818181004-5b1028a45a2f/prompt.go:84 +0x745
github.com/koinos/koinos-cli/cmd/cli/interactive.(*KoinosPrompt).Run(0xc0002b28c0)
    /Users/sgerbino/Projects/koinos-cli/cmd/cli/interactive/interactive.go:125 +0xb4
main.main()
    /Users/sgerbino/Projects/koinos-cli/cmd/cli/main.go:102 +0x66a