go-forceexport
go-forceexport copied to clipboard
Runtime error: Index out of range
I'm getting the following error when trying to run a package that uses go-forceexport. Here is the error log -
panic: runtime error: index out of range [66428884777697280] with length 15718508
goroutine 1 [running]:
github.com/rai-project/tensorflow/vendor/github.com/alangpierce/go-forceexport.FindFuncWithName(0x2b7d29a, 0x3d, 0x0, 0x0, 0xc0005bff98)
/root/gopros/src/github.com/rai-project/tensorflow/vendor/github.com/alangpierce/go-forceexport/forceexport.go:61 +0x1fc
github.com/rai-project/tensorflow/vendor/github.com/alangpierce/go-forceexport.GetFunc(0x275ae20, 0x4b33e70, 0x2b7d29a, 0x3d, 0x2fa8f80, 0xc000808090)
/root/gopros/src/github.com/rai-project/tensorflow/vendor/github.com/alangpierce/go-forceexport/forceexport.go:16 +0x30
github.com/rai-project/tensorflow/predictor.init.7()
/root/gopros/src/github.com/rai-project/tensorflow/predictor/tf_private.go:76 +0x3c
System Details: Go 1.13.10 on Linux for IBM Z/s390x
GetFunc‘s principle is to traverse the symbol table.The get func has the bug, the ftab.funcoff maybe bigger than pclntable please add
if int(ftab.funcoff) >= len(moduleData.pclntable) {
continue
}
whole func:
func FindFuncWithName(name string) (uintptr, error) {
for moduleData := &Firstmoduledata; moduleData != nil; moduleData = moduleData.next {
for _, ftab := range moduleData.ftab {
if int(ftab.funcoff) >= len(moduleData.pclntable) {
continue
}
f := (*runtime.Func)(unsafe.Pointer(&moduleData.pclntable[ftab.funcoff]))
if f.Name() == name {
return f.Entry(), nil
}
}
}
return 0, fmt.Errorf("Invalid function name: %s", name)
}