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

panic with amtool: invalid memory address or nil pointer dereference #4216

Open
jkroepke opened this issue Jan 23, 2025 · 1 comment · May be fixed by #4218
Open

panic with amtool: invalid memory address or nil pointer dereference #4216

jkroepke opened this issue Jan 23, 2025 · 1 comment · May be fixed by #4218

Comments

@jkroepke
Copy link
Member

running

amtool silence add --verbose '--start=2025-01-23T19:30:00Z' '--duration=90m' '--author=Ops Automation' '--comment=Scheduled silence: backups-vm-trv-prd-trv' '--alertmanager.url=http://alertmanager-operated.monitoring.svc.cluster.local:9093/' 'alertname=WindowsCpuUtilization' 'vmName=vm-trv-prd-trv'

results into a panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x9c1801]

goroutine 1 [running]:
github.com/prometheus/common/promslog.(*AllowedLevel).Set(0x0, {0xee4f9c, 0x5})
/go/pkg/mod/github.com/prometheus/[email protected]/promslog/slog.go:117 +0x21
github.com/prometheus/alertmanager/cli.initMatchersCompat(0xc000005c08?)
/app/cli/root.go:55 +0x66
github.com/alecthomas/kingpin/v2.(*actionMixin).applyActions(...)
/go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/actions.go:28
github.com/alecthomas/kingpin/v2.(*Application).applyActions(0xc000646700?, 0xc0000d66c0)
/go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:562 +0x5a
github.com/alecthomas/kingpin/v2.(*Application).execute(0xc000646700, 0xc0000d66c0, {0xc0000bfac0, 0x2, 0x2})
/go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:398 +0x65
github.com/alecthomas/kingpin/v2.(*Application).Parse(0xc000646700, {0xc00013e010?, 0xc00013e010?, 0xc0005617a0?})
/go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:230 +0x14a
github.com/prometheus/alertmanager/cli.Execute()
/app/cli/root.go:183 +0x12dc
main.main()
/app/cmd/amtool/main.go:19 +0xf

@jkroepke
Copy link
Member Author

jkroepke commented Jan 23, 2025

It seems that the --verbose flag trigger the panic.

alertmanager/cli/root.go

Lines 53 to 56 in d0eaa9f

promslogConfig := &promslog.Config{Writer: os.Stdout}
if verbose {
_ = promslogConfig.Level.Set("debug")
}

Since the level field is a pointer, is a nil value on initialization.


OE PROD:/root# amtool cluster show
Cluster Status:  ready
Node Name:       01JJ7DE0YP3ZDSEECZF6XE4ZVG
OE PROD:/root# amtool cluster show --verbose
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x56c0e4]

goroutine 1 [running]:
github.com/prometheus/common/promslog.(*AllowedLevel).Set(0x0, {0xa6e0b7, 0x5})
        /go/pkg/mod/github.com/prometheus/[email protected]/promslog/slog.go:117 +0x24
github.com/prometheus/alertmanager/cli.initMatchersCompat(0x9531a0?)
        /app/cli/root.go:55 +0x60
github.com/alecthomas/kingpin/v2.(*actionMixin).applyActions(...)
        /go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/actions.go:28
github.com/alecthomas/kingpin/v2.(*Application).applyActions(0x4000176300?, 0x400010c120)
        /go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:562 +0x64
github.com/alecthomas/kingpin/v2.(*Application).execute(0x4000176300, 0x400010c120, {0x4000437660, 0x2, 0x2})
        /go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:398 +0x50
github.com/alecthomas/kingpin/v2.(*Application).Parse(0x4000176300, {0x400013a010?, 0x400013a010?, 0x4000626420?})
        /go/pkg/mod/github.com/alecthomas/kingpin/[email protected]/app.go:230 +0xf0
github.com/prometheus/alertmanager/cli.Execute()
        /app/cli/root.go:183 +0x11cc
main.main()
        /app/cmd/amtool/main.go:19 +0x1c

@jkroepke jkroepke linked a pull request Jan 23, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant