Merge pull request #114 from brahmaroutu/gccgo_stacktrace_loops

avoid infinite loop with GCCGO
This commit is contained in:
Alexander Morozov 2015-07-21 11:05:09 -07:00
commit 1ed929f177
1 changed files with 5 additions and 1 deletions

View File

@ -9,13 +9,17 @@ func Capture(userSkip int) Stacktrace {
var (
skip = userSkip + 1 // add one for our own function
frames []Frame
prevPc uintptr = 0
)
for i := skip; ; i++ {
pc, file, line, ok := runtime.Caller(i)
if !ok {
//detect if caller is repeated to avoid loop, gccgo
//currently runs into a loop without this check
if !ok || pc == prevPc {
break
}
frames = append(frames, NewFrame(pc, file, line))
prevPc = pc
}
return Stacktrace{
Frames: frames,