diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2014-07-08 22:37:18 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2014-07-08 22:37:18 +0400 |
| commit | 97c8b24d01e6d60938fc499fc544ff3da9e9f726 (patch) | |
| tree | 223963c53778d187b2818adc18cd0665e75a8dcd /src/pkg/runtime/string_test.go | |
| parent | 331bf64d175805f9060160c00dbf1290ae34c303 (diff) | |
| download | go-97c8b24d01e6d60938fc499fc544ff3da9e9f726.tar.xz | |
runtime: fix spurious "[string too long]" error
Maxstring is not updated in the new string routines,
this makes runtime think that long strings are bogus.
Fixes #8339.
LGTM=crawshaw, iant
R=golang-codereviews, crawshaw, iant
CC=golang-codereviews, khr, rsc
https://golang.org/cl/110930043
Diffstat (limited to 'src/pkg/runtime/string_test.go')
| -rw-r--r-- | src/pkg/runtime/string_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pkg/runtime/string_test.go b/src/pkg/runtime/string_test.go index b05e0c7dd0..73ac95e018 100644 --- a/src/pkg/runtime/string_test.go +++ b/src/pkg/runtime/string_test.go @@ -6,6 +6,7 @@ package runtime_test import ( "runtime" + "strings" "testing" ) @@ -122,3 +123,25 @@ func TestStringW(t *testing.T) { } } } + +func TestLargeStringConcat(t *testing.T) { + output := executeTest(t, largeStringConcatSource, nil) + want := "panic: " + strings.Repeat("0", 1<<10) + strings.Repeat("1", 1<<10) + + strings.Repeat("2", 1<<10) + strings.Repeat("3", 1<<10) + if !strings.HasPrefix(output, want) { + t.Fatalf("output does not start with %q:\n%s", want, output) + } +} + +var largeStringConcatSource = ` +package main +import "strings" +func main() { + s0 := strings.Repeat("0", 1<<10) + s1 := strings.Repeat("1", 1<<10) + s2 := strings.Repeat("2", 1<<10) + s3 := strings.Repeat("3", 1<<10) + s := s0 + s1 + s2 + s3 + panic(s) +} +` |
