Fix a slice bounds out of range panic in Go offsets calculation (#1155)

* Fix a `slice bounds out of range` error in Go offsets calculation

* Change `Errorf` to `Warningf`
This commit is contained in:
M. Mert Yıldıran 2022-06-19 02:19:32 -07:00 committed by GitHub
parent 7a823e89f1
commit 167bbe3741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ import (
"github.com/Masterminds/semver"
"github.com/cilium/ebpf/link"
"github.com/knightsc/gapstone"
"github.com/up9inc/mizu/logger"
)
type goOffsets struct {
@ -145,6 +146,16 @@ func getOffsets(filePath string) (offsets map[string]*goExtendedOffset, err erro
symEndingIndex := symStartingIndex + sym.Size
// collect the bytes of the symbol
textSectionDataLen := uint64(len(textSectionData) - 1)
if symEndingIndex > textSectionDataLen {
logger.Log.Warningf(
"Skipping symbol %v, ending index %v is bigger than text section data length %v",
sym.Name,
symEndingIndex,
textSectionDataLen,
)
continue
}
symBytes := textSectionData[symStartingIndex:symEndingIndex]
// disasemble the symbol