https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65180
Bug ID: 65180 Summary: regression in gccgo testcase runtime/pprof on ppc64le, ppc64 following move to go 1.4 from 1.3 Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: go Assignee: ian at airs dot com Reporter: boger at us dot ibm.com CC: bergner at gcc dot gnu.org, cmang at google dot com Target: ppc64le, ppc64 A regression appeared in the nightly gcc testresults for the runtime/pprof in gcc 5.0 when the GO language level moved from go 1.3 to 1.4 which completed with commit id 219629. The regression appears occurs because the output is compared and the line number for one of the entries on the stack that is displayed does not match with the expected output. In inspecting the source file, it appears that the expected output is correct. The test output is off by 1 or 2. When determining the backtrace, a call is made to runtime_callers, which calls functions in libbacktrace. In two of these procedures it looks like the decrement of the pc is incorrect for Power and probably other platforms. The decremented amount for Power should be 4, but it is being decremented by 1. Once I made this change, the testcase passed but another then started failing. Here is the current failure: --- FAIL: TestMemoryProfiler (0.24s) testing.go:278: The entry did not match: 32: 1024 \[32: 1024\] @ 0x[0-9,a-f x]+ # 0x[0-9,a-f]+ pprof_test\.allocatePersistent1K\+0x[0-9,a-f]+ .*/mprof_test\.go:43 # 0x[0-9,a-f]+ runtime_pprof_test\.TestMemoryProfiler\+0x[0-9,a-f]+ .*/mprof_test\.go:66 ....... 1: 1024 [1024: 1048576] @ 0x100281db 0x100281db 0x100113fb 0x10011493 0x1000b73f 0x100c6c9f 0x1001ff53 # 0x100c6c9f testing.$thunk15+0xff /home/boger/gccgo.work/go1.4/150218/bld/../src/libgo/go/testing/testing.go:555 # 0x1001ff53 kickoff+0x43 /home/boger/gccgo.work/go1.4/150218/bld/../src/libgo/runtime/proc.c:235 32: 1024 [32: 1024] @ 0x100281db 0x100281db 0x10011aa7 0x1000b5cb 0x1000b793 0x100c6c9f 0x1001ff53 # 0x1000b5cb pprof_test.allocatePersistent1K+0x4b /home/boger/gccgo.work/go1.4/150218/bld/powerpc64le-linux/libgo/gotest49070/test/mprof_test.go:43 # 0x1000b793 runtime_pprof_test.TestMemoryProfiler+0x173 /home/boger/gccgo.work/go1.4/150218/bld/powerpc64le-linux/libgo/gotest49070/test/mprof_test.go:65 The mismatch is due to the line number specified for mprof_test.go. After some initial investigation, I found that the code in libbacktrace does not look correct for Power (ppc64, ppc64le). In both backtrace.c and simple.c, there is a decrement on the variable 'pc' which is declared as a uintptr. On Power this becomes a long int, so the decrement ends up subtracting 1 from the pointer. On Power this is not correct, because the decrement of the 'pc' should be done with multiples of 4. However, I tried to make this change but it didn't seem to help the failure. I also see that in pprof.go function printStackRecord, there is some decrementing done on the pc value, not sure if that correctly corresponds to the decrement that is done by libbacktrace. I mention these potential issues because they don't look right but they don't seem to affect the mismatch in line number and I'm not sure what is causing that.