forked from TrueCloudLab/neoneo-go
vm CLI: check whether VM is ready before jumping to the instruction
It allows to avoid panic: ``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xdab469] goroutine 1 [running]: github.com/nspcc-dev/neo-go/pkg/vm.(*VM).Jump(...) github.com/nspcc-dev/neo-go/pkg/vm/vm.go:1506 github.com/nspcc-dev/neo-go/pkg/vm/cli.handleRun(0xc0005988f0) github.com/nspcc-dev/neo-go/pkg/vm/cli/cli.go:413 +0x2e9 github.com/abiosoft/ishell/v2.(*Shell).handleCommand(0xc0004320f0, {0xc00032c7c0, 0xc0002a3920, 0x0}) github.com/abiosoft/ishell/v2@v2.0.2/ishell.go:279 +0x143 github.com/abiosoft/ishell/v2.handleInput(0xc0004320f0, {0xc00032c7c0, 0x3, 0x4}) github.com/abiosoft/ishell/v2@v2.0.2/ishell.go:233 +0x31 github.com/abiosoft/ishell/v2.(*Shell).run(0xc0004320f0) github.com/abiosoft/ishell/v2@v2.0.2/ishell.go:212 +0x30f github.com/abiosoft/ishell/v2.(*Shell).Run(0xc0004320f0) github.com/abiosoft/ishell/v2@v2.0.2/ishell.go:112 +0x28 github.com/nspcc-dev/neo-go/pkg/vm/cli.(*VMCLI).Run(0xc000224030) github.com/nspcc-dev/neo-go/pkg/vm/cli/cli.go:538 +0x39 github.com/nspcc-dev/neo-go/cli/vm.startVMPrompt(0xc0001f46e0) github.com/nspcc-dev/neo-go/cli/vm/vm.go:28 +0xb4 github.com/urfave/cli.HandleAction({0xe65fa0, 0x1161c68}, 0x2) github.com/urfave/cli@v1.22.5/app.go:524 +0xa8 github.com/urfave/cli.Command.Run({{0xfed435, 0x2}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x100576d, 0x19}, {0x0, ...}, ...}, ...) github.com/urfave/cli@v1.22.5/command.go:173 +0x652 github.com/urfave/cli.(*App).Run(0xc0001016c0, {0xc0000c6000, 0x2, 0x2}) github.com/urfave/cli@v1.22.5/app.go:277 +0x705 main.main() ./main.go:19 +0x33 ```
This commit is contained in:
parent
cbc75afd4d
commit
913e3878c5
1 changed files with 4 additions and 0 deletions
|
@ -404,6 +404,10 @@ func handleRun(c *ishell.Context) {
|
||||||
v.Estack().PushVal(params[i])
|
v.Estack().PushVal(params[i])
|
||||||
}
|
}
|
||||||
if runCurrent {
|
if runCurrent {
|
||||||
|
if !v.Ready() {
|
||||||
|
c.Err(fmt.Errorf("no program loaded"))
|
||||||
|
return
|
||||||
|
}
|
||||||
v.Jump(v.Context(), offset)
|
v.Jump(v.Context(), offset)
|
||||||
if initMD := m.ABI.GetMethod(manifest.MethodInit, 0); initMD != nil {
|
if initMD := m.ABI.GetMethod(manifest.MethodInit, 0); initMD != nil {
|
||||||
v.Call(v.Context(), initMD.Offset)
|
v.Call(v.Context(), initMD.Offset)
|
||||||
|
|
Loading…
Reference in a new issue