wetware / pkg

Peer-to-peer cloud environment
https://wetware.run
Other
38 stars 7 forks source link

Segment violation when cli does not exit with 0 code #98

Closed aratz-lasa closed 1 year ago

aratz-lasa commented 1 year ago

If we run the CLI command incorrectly, such as not passing the mandatory arguments, it raises a segment violation instead of only showing an error about lacking arguments.

Command: go run ./cmd/ww client sub

Output:

NAME:
   ww cluster subscribe - print messages from a topic

USAGE:
   ww cluster subscribe [command options] [arguments...]

OPTIONS:
   --topic value, -t value  pubsub topic
   --hex                    format output as hex (default: false)
   --help, -h               show help
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x100dcc71e]

goroutine 1 [running]:
go.uber.org/fx.(*App).StopTimeout(...)
        /Users/aratz/go/pkg/mod/go.uber.org/fx@v1.19.2/app.go:748
github.com/wetware/ww/internal/cmd/cluster.teardown.func1(0x1015440a0?)
        /Users/aratz/github.com/wetware/ww/internal/cmd/cluster/cluster.go:92 +0x3e
github.com/urfave/cli/v2.(*Command).Run.func1()
        /Users/aratz/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:195 +0x3a
github.com/urfave/cli/v2.(*Command).Run(0xc00015fce0, 0xc0001ec780, {0xc000449840, 0x1, 0x1})
        /Users/aratz/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:210 +0x77b
github.com/urfave/cli/v2.(*Command).Run(0xc0001f29a0, 0xc0001ec480, {0xc00048eaa0, 0x2, 0x2})
        /Users/aratz/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:267 +0xc4d
github.com/urfave/cli/v2.(*Command).Run(0xc0001f2dc0, 0xc0001ec140, {0xc000194090, 0x3, 0x3})
        /Users/aratz/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/command.go:267 +0xc4d
github.com/urfave/cli/v2.(*App).RunContext(0xc0003825a0, {0x10154ffd0?, 0xc00019c008}, {0xc000194090, 0x3, 0x3})
        /Users/aratz/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/app.go:332 +0x616
github.com/urfave/cli/v2.(*App).Run(...)
        /Users/aratz/go/pkg/mod/github.com/urfave/cli/v2@v2.25.1/app.go:309
main.run(0x100f1b840?)
        /Users/aratz/github.com/wetware/ww/cmd/ww/main.go:82 +0x3c
main.main()
        /Users/aratz/github.com/wetware/ww/cmd/ww/main.go:65 +0x19b
exit status 2
lthibault commented 1 year ago

Fixed in v0.1.0.