From 990621f98f691437a7dd3ee611fc72bf5676315c Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Fri, 6 Jun 2025 01:39:18 +0200 Subject: [PATCH] proc: fix nil pointer dereference in swiss table iterator (#4015) This is probably the reason for the panics reported by telemetry, the circumstances that cause this are unclear but we should be defensive about this anyway. Fixes #4005 --- pkg/proc/mapiter.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/proc/mapiter.go b/pkg/proc/mapiter.go index 19a855dc..a2997b7a 100644 --- a/pkg/proc/mapiter.go +++ b/pkg/proc/mapiter.go @@ -349,6 +349,7 @@ var errSwissTableCouldNotLoad = errors.New("could not load one of the tables") var errSwissMapBadType = errors.New("swiss table type does not have some required fields") var errSwissMapBadTableField = errors.New("swiss table bad table field") var errSwissMapBadGroupTypeErr = errors.New("bad swiss map type, group type lacks some required fields") +var errSwissTableNilGroups = errors.New("bad swiss map, groups pointer is nil") // loadTypes determines the correct type for it.dirPtr: the linker records // this type as **table but in reality it is either *[dirLen]*table for @@ -566,6 +567,11 @@ func (it *mapIteratorSwiss) loadCurrentTable() { r.groups.RealType = r.groups.DwarfType r.groups = r.groups.maybeDereference() + if r.groups.Addr == 0 { + it.v.Unreadable = errSwissTableNilGroups + return + } + it.tab = r }