avoid infinite loop with GCCGO
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
This commit is contained in:
parent
a88b26d3ac
commit
23e3887e05
|
@ -9,13 +9,17 @@ func Capture(userSkip int) Stacktrace {
|
||||||
var (
|
var (
|
||||||
skip = userSkip + 1 // add one for our own function
|
skip = userSkip + 1 // add one for our own function
|
||||||
frames []Frame
|
frames []Frame
|
||||||
|
prevPc uintptr = 0
|
||||||
)
|
)
|
||||||
for i := skip; ; i++ {
|
for i := skip; ; i++ {
|
||||||
pc, file, line, ok := runtime.Caller(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
|
break
|
||||||
}
|
}
|
||||||
frames = append(frames, NewFrame(pc, file, line))
|
frames = append(frames, NewFrame(pc, file, line))
|
||||||
|
prevPc = pc
|
||||||
}
|
}
|
||||||
return Stacktrace{
|
return Stacktrace{
|
||||||
Frames: frames,
|
Frames: frames,
|
||||||
|
|
Loading…
Reference in New Issue