On Thu, Jul 28, 2016 at 4:24 AM, Uros Bizjak <[email protected]> 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?
Ian
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>"