Skip to content

Commit 7bc2b0c

Browse files
fix zero id mapping case
1 parent c5b4159 commit 7bc2b0c

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

merge.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import (
1313
"google.golang.org/protobuf/proto"
1414
)
1515

16+
const (
17+
UnsymbolizableLocationAddress = 0x0
18+
)
19+
1620
type functionKey struct {
1721
name, systemName, filename, startLine int64
1822
}
@@ -641,13 +645,19 @@ func (pw *ProfileMerger) putLocation(src *Location, p *Profile) uint64 {
641645
return math.MaxUint64
642646
}
643647

644-
loc := &MergeLocation{
645-
MappingId: pw.putMapping(p.Mapping[src.MappingId-1], p),
646-
Address: src.Address,
647-
Line: make([]*MergeLine, len(src.Line), len(src.Line)),
648-
IsFolded: src.IsFolded,
648+
loc := &MergeLocation{}
649+
if src.MappingId == 0 && len(src.Line) == 0 {
650+
loc.Address = UnsymbolizableLocationAddress
649651
}
650652

653+
if src.MappingId != 0 {
654+
loc.MappingId = pw.putMapping(p.Mapping[src.MappingId-1], p)
655+
loc.Address = src.Address
656+
}
657+
658+
loc.IsFolded = src.IsFolded
659+
loc.Line = make([]*MergeLine, len(src.Line), len(src.Line))
660+
651661
for i, line := range src.Line {
652662
loc.Line[i] = pw.putLine(line, p)
653663
}

0 commit comments

Comments
 (0)