Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pkg): make sure the config entrypoint/cmd exist before looping over them #44

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

francesco-racciatti
Copy link
Collaborator

@francesco-racciatti francesco-racciatti commented Apr 22, 2024

This PR fixes a potential sigsegv that may occur when the configuration gets an empty entrypoint/command.

(dlv) bt
 0  0x0000000000443ea4 in runtime.fatalpanic
    at /usr/local/go/src/runtime/panic.go:1217
...
 3  0x000000000045bdc5 in runtime.sigpanic
    at /usr/local/go/src/runtime/signal_unix.go:881
* 4  0x0000000000c842d1 in github.com/go-akka/configuration/hocon.(*HoconValue).GetArray
    at /go/pkg/mod/github.com/go-akka/[email protected]/hocon/value.go:370
* 5  0x0000000000c89c05 in github.com/sysdiglabs/agent-kilt/pkg/kilt.applyPatch
    at /go/pkg/mod/github.com/sysdiglabs/agent-kilt/[email protected]/kilt/build.go:157
 6  0x0000000000c8d925 in github.com/sysdiglabs/agent-kilt/pkg/kilt.(*KiltHocon).patchContainerDefinitions
    at /go/pkg/mod/github.com/sysdiglabs/agent-kilt/[email protected]/kilt/hocon.go:107
 7  0x0000000000c8e8d0 in github.com/sysdiglabs/agent-kilt/pkg/kilt.(*KiltHocon).PatchTaskDefinition
...
(dlv)

pkg.kilt got an empty array (from config.entrypoint in this case)

(dlv) frame 4
> [unrecovered-panic] runtime.fatalpanic() /usr/local/go/src/runtime/panic.go:1217 (hits goroutine(1):1 total:1) (PC: 0x443ea4)
Warning: debugging optimized function
Frame 4: /go/pkg/mod/github.com/go-akka/[email protected]/hocon/value.go:370 (PC: c842d1)
(dlv) locals
arrs = []*github.com/go-akka/configuration/hocon.HoconValue len: 0, cap: 0, nil
(dlv) args
p = *github.com/go-akka/configuration/hocon.HoconValue nil
~r0 = []*github.com/go-akka/configuration/hocon.HoconValue len: 0, cap: 0, nil
(dlv)
(dlv) frame 5
> [unrecovered-panic] runtime.fatalpanic() /usr/local/go/src/runtime/panic.go:1217 (hits goroutine(1):1 total:1) (PC: 0x443ea4)
Warning: debugging optimized function
Frame 5: /go/pkg/mod/github.com/sysdiglabs/agent-kilt/[email protected]/kilt/build.go:157 (PC: c89c05)
(dlv) locals
err = error nil
entryPoint = ("*github.com/Jeffail/gabs/v2.Container")(0xc0004df4f0)
(dlv) args
container = ("*github.com/Jeffail/gabs/v2.Container")(0xc0004de190)
config = ("*github.com/go-akka/configuration.Config")(0xc000262690)
patchConfig = ("*github.com/sysdiglabs/agent-kilt/pkg/kilt.PatchConfig")(0xc000527666)
~r0 = map[string]*github.com/Jeffail/gabs/v2.Container nil
~r1 = error nil

Copy link
Collaborator

@pgcrooks-sysdig pgcrooks-sysdig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants