Skip to content

Crash trying to list traces #87

@dalehamel

Description

@dalehamel
$ kubectl trace get
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1d02385]

goroutine 1 [running]:
github.com/iovisor/kubectl-trace/pkg/tracejob.(*TraceJobClient).GetJob(0xc00066fc90, 0x0, 0x0, 0x0, 0x1d00903, 0xc00000c3c0, 0x0, 0x0)
	/Users/dalehamel/workspace/kubectl-trace/pkg/tracejob/job.go:135 +0x375
github.com/iovisor/kubectl-trace/pkg/cmd.(*GetOptions).Run(0xc0005a3280, 0x21af8e0, 0xc000379b00)
	/Users/dalehamel/workspace/kubectl-trace/pkg/cmd/get.go:163 +0x274
github.com/iovisor/kubectl-trace/pkg/cmd.NewGetCommand.func2(0xc0003d4000, 0x2a8f058, 0x0, 0x0, 0x0, 0x0)
	/Users/dalehamel/workspace/kubectl-trace/pkg/cmd/get.go:88 +0x94
github.com/spf13/cobra.(*Command).execute(0xc0003d4000, 0x2a8f058, 0x0, 0x0, 0xc0003d4000, 0x2a8f058)
	/Users/dalehamel/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:762 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002d7900, 0xc0000da000, 0x215ede0, 0xc0000e6000)
	/Users/dalehamel/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x2ea
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/dalehamel/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800
main.main()
	/Users/dalehamel/workspace/kubectl-trace/cmd/kubectl-trace/root.go:24 +0x10e

Appears to be this https://github.com/iovisor/kubectl-trace/blob/master/pkg/tracejob/job.go#L134 (note my local file is different line num)

It looks like if you try to list the trace jobs before their are any, reading this is trying to read invalid memory. We probably need to check that it's safe to navigate the status struct before trying to access its members.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions