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

Adding filtering host events as described in Hello world gadget tutorial causes segmentation violation #2873

Closed
Sefi4 opened this issue May 20, 2024 · 2 comments · Fixed by #2874

Comments

@Sefi4
Copy link

Sefi4 commented May 20, 2024

Description

I followed the hello world gadget tutorial as described here: https://www.inspektor-gadget.io/docs/latest/devel/hello-world-gadget/.

Everything worked fine, until getting to "Filtering and container enrichement" section:
https://www.inspektor-gadget.io/docs/latest/devel/hello-world-gadget/#filtering-and-container-enrichement
(BTW there's a typo in the section title it should be enrichment instead of enrichement).

When adding the host filtering part as described in the tutorial I receive the following error:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x20720bd]

goroutine 1 [running]:
github.com/inspektor-gadget/inspektor-gadget/pkg/operators/localmanager.(*localManagerTraceWrapper).PreStart(0xc003992080, {0x2d8c008, 0xc0030f9c80})
/go/src/github.com/inspektor-gadget/inspektor-gadget/pkg/operators/localmanager/localmanager.go:532 +0xbd
github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-context.(*GadgetContext).run(0xc0030f9c80, {0xc0031cf1d0, 0x3, 0x17?})
/go/src/github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-context/run.go:103 +0x197
github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-context.(*GadgetContext).Run(0xc0030f9c80, 0xc000050f40?)
/go/src/github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-context/run.go:167 +0x9e
github.com/inspektor-gadget/inspektor-gadget/pkg/runtime/local.(*Runtime).RunGadget(0x22d4f60?, {0x2db2d60?, 0xc0030f9c80?}, 0xd?, 0xc002af5b80?)
/go/src/github.com/inspektor-gadget/inspektor-gadget/pkg/runtime/local/oci.go:35 +0x27
github.com/inspektor-gadget/inspektor-gadget/cmd/common.NewRunCommand.func2(0xc00039c608, {0xc00037f440?, 0x2?, 0x2?})
/go/src/github.com/inspektor-gadget/inspektor-gadget/cmd/common/oci.go:180 +0x6d7
github.com/spf13/cobra.(*Command).execute(0xc00039c608, {0xc00037f440, 0x2, 0x2})
/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc0004f6908)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
main.main()
/go/src/github.com/inspektor-gadget/inspektor-gadget/cmd/ig/main.go:91 +0x374

Impact

Can't add host filtering to hello world gadget.

Environment and steps to reproduce

  1. Set-up: I use WSL with Docker Desktop v4.30.0.
  2. Task: Adding the host filtering part to the hello world gadget (copy pasting from the tutorial).
  3. Action(s): Follow the "Filtering and container enrichement" as described in: https://www.inspektor-gadget.io/docs/latest/devel/hello-world-gadget/#filtering-and-container-enrichement
  4. Error: INFO[0000] Experimental features enabled
    WARN[0000] you set --verify-image=false, image will not be verified
    WARN[0000] failed to get cgroups info of container 3ebd135cf445cd857c2c42bf5a923b704de1106efa9a837c8206a2dcae5c8c0f from /proc/341/cgroup: parsing cgroup: open /proc/341/cgroup: no such file or directory
    WARN[0000] Failed to create container-collection
    WARN[0000] you set --verify-image=false, image will not be verified
    WARN[0000] failed to get cgroups info of container 3ebd135cf445cd857c2c42bf5a923b704de1106efa9a837c8206a2dcae5c8c0f from /proc/341/cgroup: parsing cgroup: open /proc/341/cgroup: no such file or directory
    WARN[0001] Failed to create container-collection
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x20720bd]

goroutine 1 [running]:
github.com/inspektor-gadget/inspektor-gadget/pkg/operators/localmanager.(*localManagerTraceWrapper).PreStart(0xc003992080, {0x2d8c008, 0xc0030f9c80})
/go/src/github.com/inspektor-gadget/inspektor-gadget/pkg/operators/localmanager/localmanager.go:532 +0xbd
github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-context.(*GadgetContext).run(0xc0030f9c80, {0xc0031cf1d0, 0x3, 0x17?})
/go/src/github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-context/run.go:103 +0x197
github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-context.(*GadgetContext).Run(0xc0030f9c80, 0xc000050f40?)
/go/src/github.com/inspektor-gadget/inspektor-gadget/pkg/gadget-context/run.go:167 +0x9e
github.com/inspektor-gadget/inspektor-gadget/pkg/runtime/local.(*Runtime).RunGadget(0x22d4f60?, {0x2db2d60?, 0xc0030f9c80?}, 0xd?, 0xc002af5b80?)
/go/src/github.com/inspektor-gadget/inspektor-gadget/pkg/runtime/local/oci.go:35 +0x27
github.com/inspektor-gadget/inspektor-gadget/cmd/common.NewRunCommand.func2(0xc00039c608, {0xc00037f440?, 0x2?, 0x2?})
/go/src/github.com/inspektor-gadget/inspektor-gadget/cmd/common/oci.go:180 +0x6d7
github.com/spf13/cobra.(*Command).execute(0xc00039c608, {0xc00037f440, 0x2, 0x2})
/go/pkg/mod/github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc0004f6908)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:1039
main.main()
/go/src/github.com/inspektor-gadget/inspektor-gadget/cmd/ig/main.go:91 +0x374

Expected behavior

The hello world gadget is ran as described in the tutorial.

Additional information

I'm running the image based gadget with --image-verify=false because of another issue I was experiencing with the tutorial:
#2872 (comment)

Please add any information here that does not fit the above format.

@mauriciovasquezbernal
Copy link
Member

@Sefi4 thanks a lot for opening this issue. It'll be fixed by #2874.

In the mean time, if you want to continue experimenting you can install runc or docker or another container runtime.

@alban
Copy link
Member

alban commented May 20, 2024

Set-up: I use WSL with Docker Desktop v4.30.0.

#2874 should fix the panic but you will need #2875 as well if you start ig directly from a WSL shell and not within a docker container.

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