From c5e31465f9558a0510d9a3fe4bbc1709fffbca35 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 10 Jul 2015 18:19:58 +0000 Subject: [PATCH] stacktrace loops infinitely on GCCGO, this fixes the issue Signed-off-by: Srini Brahmaroutu --- check.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/check.go b/check.go index f302a05..6203aa2 100644 --- a/check.go +++ b/check.go @@ -282,13 +282,15 @@ func (c *C) logCaller(skip int) { var testFile string var testLine int testFunc := runtime.FuncForPC(c.method.PC()) + var prevPc uintptr = 0 if runtime.FuncForPC(pc) != testFunc { for { skip += 1 - if pc, file, line, ok := runtime.Caller(skip); ok { + if pc, file, line, ok := runtime.Caller(skip); ok && pc != prevPc { // Note that the test line may be different on // distinct calls for the same test. Showing // the "internal" line is helpful when debugging. + prevPc = pc if runtime.FuncForPC(pc) == testFunc { testFile, testLine = file, line break @@ -322,8 +324,10 @@ var asmGo = filepath.Join("runtime", "asm_") func (c *C) logPanic(skip int, value interface{}) { skip++ // Our own frame. initialSkip := skip + var prevPc uintptr = 0 for ; ; skip++ { - if pc, file, line, ok := runtime.Caller(skip); ok { + if pc, file, line, ok := runtime.Caller(skip); ok && pc != prevPc { + prevPc = pc if skip == initialSkip { c.logf("... Panic: %s (PC=0x%X)\n", value, pc) }