-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gccgo: regression in gcc 5.2.1 in gccgo testcase 235.go on ppc64le, ppc64 #13662
Comments
That's not good. The only effect of that change is to change when the garbage collector runs. If that causes the test to fail, then I think there must be something wrong with the garbage collector. |
After further debugging I find that it fails if compiled with -O2 but passes without. Must be an optimization bug, I'll investigate further. |
I've tried various experiments. It does appear to be a GC issue with freeing something too early. I can't get it to fail on gcc6; on gcc5 it passes without optimization, passes at -O2 if I set GOGC=off. After adding print statements I see that 'F' gets trashed before it gets in the case where it fails.
./235 If I add a print statement right after F is initialized, then the values are good and the test passes. I don't know enough about what GC does or how it decides it shouldn't free something. Must be something unique about this testcase or else we'd be seeing lots of GC problems? |
I've done some investigation on this and there are two things that don't seem right for the gcc 5 branch with gccgo on Power. First, the failure started happening with commit 227785, with the change to subtract off the value of runtime_stacks_sys from the next_gc value. On Power in gcc5, split stack support was not backported so the value of runtime_stacks_sys is a large value, which means next_gc is not being set to a high value as described in the comments. (In other words, the value of runtime_stacks_sys is likely to be a large portion of the total heap at the beginning). Instead the next run of GC is done soon. The problem doesn't happen on gcc6 because of the split stack implementation or the effect of this patch https://gcc.gnu.org/ml/gcc-patches/2015-10/msg03503.html, both of which keep runtime_stacks_sys as a low value. But as was noted above, running GC more frequently shouldn't cause a failure so there also seems to be a problem related to the use of GC with optimized code. I found that if the pointer returned from a heap allocation is kept in a register and never stored then it is being freed too early by GC causing the failure in this test. When next_gc is a low value and the next GC is done soon this problem is more likely to occur.
By the time the call is made to memcpy, the storage containing the values that should be copied have been garbage collected and the values are 0. When compiled without optimization, the pointer is stored and the failure does not occur. |
Thanks for looking into this. It shouldn't matter that r3 is not stored, because the value was copied into r27. Presumably the fmt.Printf, where the problem appears, is using r27 to retrieve the values. What puzzles me, looking at the partial disassembly, is the |
I think the problem can be avoided by using the -fno-ivopts option, but it would be unfortunate to require that for all Go code. |
I asked a question about this on the GCC mailing list: https://gcc.gnu.org/ml/gcc/2016-01/msg00023.html . |
FYI... Original problem was reported on gccgo from gcc 5.2.1, and did not fail If I build the test with gccgo from trunk using -O2 and use GOGC=10 then On 01/06/2016 09:19 AM, Ian Lance Taylor wrote:
|
This is fixed on trunk. Leaving open for now for the possibility of a backport to the GCC 5 branch. |
We don't care about a backport of this to the gcc5 branch, so if you want to close it that's fine. |
This regression has been around since 5.2.1, and started failing with r227785 on the gcc release 5 branch. You can see the failures in the gcc-testresults output for ppc64le and ppc64 consistently since then. If I remove that change the testcase passes. It does not fail on trunk.
Here is the information from go.log:
Setting GOARCH=ppc64le
Executing on host: /home/boger/gccgo.work/gcc5.0/bld/gcc/testsuite/go/../../gccgo -B/home/boger/gccgo.work/gcc5.0/bld/gcc/testsuite/go/../../ /home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go -fno-diagnostics-show-caret -fdiagnostics-color=never -I/home/boger/gccgo.work/gcc5.0/bld/powerpc64le-linux/./libgo -w -O2 -g -L/home/boger/gccgo.work/gcc5.0/bld/powerpc64le-linux/./libgo -L/home/boger/gccgo.work/gcc5.0/bld/powerpc64le-linux/./libgo/.libs -lm -o /home/boger/gccgo.work/gcc5.0/bld/gcc/testsuite/go/235.x (timeout = 300)
spawn /home/boger/gccgo.work/gcc5.0/bld/gcc/testsuite/go/../../gccgo -B/home/boger/gccgo.work/gcc5.0/bld/gcc/testsuite/go/../../ /home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go -fno-diagnostics-show-caret -fdiagnostics-color=never -I/home/boger/gccgo.work/gcc5.0/bld/powerpc64le-linux/./libgo -w -O2 -g -L/home/boger/gccgo.work/gcc5.0/bld/powerpc64le-linux/./libgo -L/home/boger/gccgo.work/gcc5.0/bld/powerpc64le-linux/./libgo/.libs -lm -o /home/boger/gccgo.work/gcc5.0/bld/gcc/testsuite/go/235.x^M
PASS: go.test/test/235.go compilation, -O2 -g
Setting LD_LIBRARY_PATH to .:/home/boger/gccgo.work/gcc5.0/bld/powerpc64le-linux/./libgo/.libs:/home/boger/gccgo.work/gcc5.0/bld/gcc:.:/home/boger/gccgo.work/gcc5.0/bld/powerpc64le-linux/./libgo/.libs:/home/boger/gccgo.work/gcc5.0/bld/gcc:/usr/local/gccgo/lib64
spawn [open ...]^M
bad: 0 should be 2
panic: 235
goroutine 16 [running]:
main.main
/home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go:72
created by main
/home/boger/gccgo.work/gcc5.0/bld/../src/libgo/runtime/go-main.c:48
goroutine 19 [chan receive]:
main.$nested0
/home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go:19
created by main.M
/home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go:17
goroutine 20 [chan receive]:
main.$nested0
/home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go:19
created by main.M
/home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go:17
goroutine 21 [chan receive]:
main.$nested0
/home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go:19
created by main.M
/home/boger/gccgo.work/gcc5.0/src/gcc/testsuite/go.test/test/235.go:17
FAIL: go.test/test/235.go execution, -O2 -g
The text was updated successfully, but these errors were encountered: