Message ID | CAOyqgcVjyFAvSOTn=vFkMkkcyX0cH_KnYWqgxDtV_KrVfi6Ftg@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Thu, Aug 4, 2016 at 12:53 AM, Ian Lance Taylor <iant@golang.org> wrote: > On Thu, Jul 28, 2016 at 4:24 AM, Uros Bizjak <ubizjak@gmail.com> wrote: >> >> A new testsuite failure is introduced: >> >> FAIL: text/template >> >> on both, x86_64-linux-gnu and alpha-linux-gnu. >> >> The testcase corrupts stack with a too deep recursion. >> >> There is a part in libgo/go/text/template/exec.go that should handle >> this situaiton: >> >> // maxExecDepth specifies the maximum stack depth of templates within >> // templates. This limit is only practically reached by accidentally >> // recursive template invocations. This limit allows us to return >> // an error instead of triggering a stack overflow. >> const maxExecDepth = 100000 >> >> but the limit is either set too high, or the error handling code is >> inefficient on both, split-stack (x86_64) and non-split-stack (alpha) >> targets. Lowering this value to 10000 "fixes" the testcase on both >> targets. > > I can not recreate this problem on x86 or x86_64. > > Does this patch work around the problem on Alpha? Yes, the patch "fixes" the problem on alpha, but I still see the failure on x86_64, even with the unlimited stack. This is on Fedora 24, x86_64: $ gmake -j 12 text/template/check /home/uros/gcc-svn/trunk/libgo/testsuite/gotest: line 622: 4556 Segmentation fault (core dumped) ./a.out -test.short -test.timeout=${timeout}s "$@" FAIL: text/template Makefile:6285: recipe for target 'text/template/check' failed gmake: *** [text/template/check] Error 1 $ ulimit -s unlimited Running the test under gdb: (gdb) r Starting program: /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/a.out [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x2aaaae93c700 (LWP 31972)] [New Thread 0x2aaaaf740700 (LWP 31973)] [New Thread 0x2aaaaf941700 (LWP 31974)] Thread 1 "a.out" received signal SIGSEGV, Segmentation fault. __generic_morestack (pframe_size=0x2aaaaff04170, old_stack=0x2aaaaff04190, param_size=0) at /home/uros/gcc-svn/trunk/libgcc/generic-morestack.c:573 573 current->old_stack = old_stack; (gdb) c Continuing. Thread 1 "a.out" received signal SIGSEGV, Segmentation fault. __generic_morestack (pframe_size=0x2aaaaff03aa0, old_stack=0x2aaaaff03ac0, param_size=0) at /home/uros/gcc-svn/trunk/libgcc/generic-morestack.c:573 573 current->old_stack = old_stack; (gdb) c Continuing. [Thread 0x2aaaaf941700 (LWP 31974) exited] [Thread 0x2aaaaf740700 (LWP 31973) exited] [Thread 0x2aaaae93c700 (LWP 31972) exited] Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists. (gdb) Manually running the testcase: [uros@localhost test]$ LD_LIBRARY_PATH=../../.libs ./a.out fatal error: unexpected signal during runtime execution [signal 0xb code=0x1 addr=0x47] runtime stack: runtime_dopanic /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:135 runtime_throw /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:193 sig_panic_leadin /home/uros/gcc-svn/trunk/libgo/runtime/go-signal.c:249 sig_panic_info_handler /home/uros/gcc-svn/trunk/libgo/runtime/go-signal.c:283 :0 scanblock /home/uros/gcc-svn/trunk/libgo/runtime/mgc0.c:1005 gc /home/uros/gcc-svn/trunk/libgo/runtime/mgc0.c:2271 mgc /home/uros/gcc-svn/trunk/libgo/runtime/mgc0.c:2215 runtime_mstart /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:1076 goroutine 392 [garbage collection]: runtime_mcall /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:295 runtime_gc /home/uros/gcc-svn/trunk/libgo/runtime/mgc0.c:2191 runtime_mallocgc /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:259 text_template.walkTemplate.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:382 text_template.walk.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:239 text_template.walk.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:234 text_template.walkTemplate.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:383 text_template.walk.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:239 text_template.walk.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:234 text_template.walkTemplate.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:383 text_template.walk.pN19_text_template.state [...] /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:239 text_template.walk.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:234 text_template.walkTemplate.pN19_text_template.state /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/exec.go:383 created by testing.Run.pN9_testing.T /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:645 goroutine 16 [chan receive]: runtime_mcall /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:295 chanrecv /home/uros/gcc-svn/trunk/libgo/runtime/chan.goc:269 testing.Run.pN9_testing.T /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:646 testing.$nested9 /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:792 testing.tRunner /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:609 testing.RunTests /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:790 testing.Run.pN9_testing.M /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:742 main.main /ssd/uros/gcc-build/x86_64-pc-linux-gnu/libgo/gotest26048/test/_testmain.go:64 runtime_main /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:626 created by main /home/uros/gcc-svn/trunk/libgo/runtime/go-main.c:54 goroutine 17 [syscall]: goroutine in C code; stack unavailable created by runtime_main /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:598 goroutine 18 [finalizer wait]: runtime_mcall /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:295 runfinq /home/uros/gcc-svn/trunk/libgo/runtime/mgc0.c:2512 kickoff /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:235 created by runtime_createfing /home/uros/gcc-svn/trunk/libgo/runtime/mgc0.c:2577 goroutine 20 [runnable]: runtime_mcall /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:295 bgsweep /home/uros/gcc-svn/trunk/libgo/runtime/mgc0.c:1833 kickoff /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:235 created by mgc /home/uros/gcc-svn/trunk/libgo/runtime/mgc0.c:2215 BTW: I can see this failure on other targets, too, e.g. powerpc64le [1] and aarch64 [2]. [1] https://gcc.gnu.org/ml/gcc-testresults/2016-08/msg00321.html [2] https://gcc.gnu.org/ml/gcc-testresults/2016-08/msg00318.html Uros.
Hi Uros, > BTW: I can see this failure on other targets, too, e.g. powerpc64le > [1] and aarch64 [2]. > > [1] https://gcc.gnu.org/ml/gcc-testresults/2016-08/msg00321.html > [2] https://gcc.gnu.org/ml/gcc-testresults/2016-08/msg00318.html right, both Solaris/x86 and Solaris/SPARC are affected, too (32 and 64-bit in both cases). Rainer
diff --git a/libgo/go/text/template/exec_test.go b/libgo/go/text/template/exec_test.go index 3ef065e..6319706 100644 --- a/libgo/go/text/template/exec_test.go +++ b/libgo/go/text/template/exec_test.go @@ -11,6 +11,7 @@ import ( "fmt" "io/ioutil" "reflect" + "runtime" "strings" "testing" ) @@ -1299,6 +1300,10 @@ func TestMissingFieldOnNil(t *testing.T) { } func TestMaxExecDepth(t *testing.T) { + // Don't try to run this test if stack space is limited. + if runtime.Compiler == "gccgo" && runtime.GOARCH != "amd64" && runtime.GOARCH != "386" { + t.Skipf("skipping on gccgo GOARCH %s", runtime.GOARCH) + } tmpl := Must(New("tmpl").Parse(`{{template "tmpl" .}}`)) err := tmpl.Execute(ioutil.Discard, nil) got := "<nil>"