You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ go1.11 version
go version go1.11.4 darwin/amd64
$ go version
go version devel +4b3f04c63b Thu Jan 10 18:15:48 2019 +0000 darwin/amd64
$ go-tip version
go version devel +70931c087b Mon Jan 14 19:44:57 2019 +0000 darwin/amd64
Does this issue reproduce with the latest release?
The issue is present in go1.12beta2 and in the current HEAD of master.
I bisected and found that 956879d (for #29582) introduced the issue.
I have a package that calls runtime.FuncForPC several times, sometimes with PCs that don't correspond to function bodies. Previously, the returned *runtime.Func would correspond to a nearby function. Now, runtime.FuncForPC throws a fatal error.
package main
import (
"fmt"
"runtime"
)
func main() {
var stack [1]uintptr
runtime.Callers(1, stack[:])
prev := ""
for i := 0; i < 1000; i++ {
fn := runtime.FuncForPC(stack[0] + uintptr(i))
name := fn.Name()
if prev != name {
fmt.Println(name)
prev = name
}
}
}
What did you expect to see?
I expected calls to runtime.FuncForPC with invalid arguments to return nil or a nearby *runtime.Func.
$ go1.11 run /tmp/repro.go
main.main
main.init
What did you see instead?
The function instead throws a fatal error, immediately halting the program.
Not really supported behavior, but we should probably fix it.
For PCs which occur after the last instruction of a function, but before the first instruction of the next function (which exist because we pad to align function starts to 16 bytes), we get in trouble. findfunc returns the previous function, but the pcln tables don't cover those instructions. We now need the pcln tables to figure out whether that pc is in an inlined function or not.
We should really have findfunc return nil for those instructions. Unfortunately, we don't have the function size anywhere convenient at runtime. I'll see if I can find a way to make that happen.
The other solution is to extend the pcln tables to cover the padding instructions, and/or have the pcln reader not barf if we read off the end of the table.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
The issue is present in go1.12beta2 and in the current HEAD of master.
I bisected and found that 956879d (for #29582) introduced the issue.
CC @randall77 @ianlancetaylor
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have a package that calls
runtime.FuncForPC
several times, sometimes with PCs that don't correspond to function bodies. Previously, the returned*runtime.Func
would correspond to a nearby function. Now,runtime.FuncForPC
throws a fatal error.What did you expect to see?
I expected calls to
runtime.FuncForPC
with invalid arguments to return nil or a nearby*runtime.Func
.What did you see instead?
The function instead throws a fatal error, immediately halting the program.
The text was updated successfully, but these errors were encountered: