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
This commit is contained in:
Alessandro Arzilli
2025-06-06 01:39:18 +02:00
committed by GitHub
parent 89c6cd4f34
commit 990621f98f

View File

@ -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 errSwissMapBadType = errors.New("swiss table type does not have some required fields")
var errSwissMapBadTableField = errors.New("swiss table bad table field") var errSwissMapBadTableField = errors.New("swiss table bad table field")
var errSwissMapBadGroupTypeErr = errors.New("bad swiss map type, group type lacks some required fields") 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 // loadTypes determines the correct type for it.dirPtr: the linker records
// this type as **table but in reality it is either *[dirLen]*table for // 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.RealType = r.groups.DwarfType
r.groups = r.groups.maybeDereference() r.groups = r.groups.maybeDereference()
if r.groups.Addr == 0 {
it.v.Unreadable = errSwissTableNilGroups
return
}
it.tab = r it.tab = r
} }