go-forceexport icon indicating copy to clipboard operation
go-forceexport copied to clipboard

Runtime error: Index out of range

Open Masquerade0097 opened this issue 4 years ago • 3 comments

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

Masquerade0097 avatar May 13 '20 14:05 Masquerade0097

image

A0nameless0man avatar Jul 09 '21 03:07 A0nameless0man

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)
}

saikei avatar Jul 26 '21 08:07 saikei