From 88d719f8092c250f3575cc8e136090b3db65ee15 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Wed, 6 Mar 2019 09:56:03 -0500 Subject: [PATCH] go/internal/gccgoimporter: test case for issue 30628 Test case for a panic/crash in gccgoimporter caused by incorrect gccgo export data emission. Note that the *.gox file checked in contains the correct export data; the main intent of the test is to make sure that gccgo produces the right export data when run on the Go source. Updates #30628 Change-Id: I29c0c17b81a43f92ff64fbfcdc58fdb46a5be370 Reviewed-on: https://go-review.googlesource.com/c/go/+/165739 Run-TryBot: Than McIntosh Reviewed-by: Robert Griesemer Reviewed-by: Ian Lance Taylor TryBot-Result: Gobot Gobot --- .../internal/gccgoimporter/importer_test.go | 1 + .../gccgoimporter/testdata/issue30628.go | 18 ++++++++++++ .../gccgoimporter/testdata/issue30628.gox | 28 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 src/go/internal/gccgoimporter/testdata/issue30628.go create mode 100644 src/go/internal/gccgoimporter/testdata/issue30628.gox diff --git a/src/go/internal/gccgoimporter/importer_test.go b/src/go/internal/gccgoimporter/importer_test.go index 58fa8c8cf5..ee01883203 100644 --- a/src/go/internal/gccgoimporter/importer_test.go +++ b/src/go/internal/gccgoimporter/importer_test.go @@ -91,6 +91,7 @@ var importerTests = [...]importerTest{ {pkgpath: "v1reflect", name: "Type", want: "type Type interface{Align() int; AssignableTo(u Type) bool; Bits() int; ChanDir() ChanDir; Elem() Type; Field(i int) StructField; FieldAlign() int; FieldByIndex(index []int) StructField; FieldByName(name string) (StructField, bool); FieldByNameFunc(match func(string) bool) (StructField, bool); Implements(u Type) bool; In(i int) Type; IsVariadic() bool; Key() Type; Kind() Kind; Len() int; Method(int) Method; MethodByName(string) (Method, bool); Name() string; NumField() int; NumIn() int; NumMethod() int; NumOut() int; Out(i int) Type; PkgPath() string; Size() uintptr; String() string; common() *commonType; rawString() string; runtimeType() *runtimeType; uncommon() *uncommonType}"}, {pkgpath: "nointerface", name: "I", want: "type I int"}, {pkgpath: "issue29198", name: "FooServer", want: "type FooServer struct{FooServer *FooServer; user string; ctx context.Context}"}, + {pkgpath: "issue30628", name: "Apple", want: "type Apple struct{hey sync.RWMutex; x int; RQ [517]struct{Count uintptr; NumBytes uintptr; Last uintptr}}"}, } func TestGoxImporter(t *testing.T) { diff --git a/src/go/internal/gccgoimporter/testdata/issue30628.go b/src/go/internal/gccgoimporter/testdata/issue30628.go new file mode 100644 index 0000000000..8fd7c13d7b --- /dev/null +++ b/src/go/internal/gccgoimporter/testdata/issue30628.go @@ -0,0 +1,18 @@ +package issue30628 + +import ( + "os" + "sync" +) + +const numR = int32(os.O_TRUNC + 5) + +type Apple struct { + hey sync.RWMutex + x int + RQ [numR]struct { + Count uintptr + NumBytes uintptr + Last uintptr + } +} diff --git a/src/go/internal/gccgoimporter/testdata/issue30628.gox b/src/go/internal/gccgoimporter/testdata/issue30628.gox new file mode 100644 index 0000000000..0ff6259dd0 --- /dev/null +++ b/src/go/internal/gccgoimporter/testdata/issue30628.gox @@ -0,0 +1,28 @@ +v3; +package issue30628 +pkgpath issue30628 +import os os "os" +import sync sync "sync" +init cpu internal..z2fcpu..import poll internal..z2fpoll..import testlog internal..z2ftestlog..import io io..import os os..import runtime runtime..import sys runtime..z2finternal..z2fsys..import sync sync..import syscall syscall..import time time..import +init_graph 1 0 1 3 1 5 1 6 1 7 1 8 1 9 3 0 3 5 3 6 3 7 4 0 4 1 4 2 4 3 4 5 4 6 4 7 4 8 4 9 5 0 5 6 7 0 7 5 7 6 8 0 8 5 8 6 8 7 9 0 9 5 9 6 9 7 9 8 +types 13 2 24 84 208 17 30 41 147 86 17 64 25 75 +type 1 "Apple" +type 2 struct { .issue30628.hey ; .issue30628.x ; RQ ; } +type 3 "sync.RWMutex" + func (rw ) Lock () + func (rw ) RLocker () ($ret8 ) + func (rw ) RUnlock () + func (rw ) Unlock () + func (rw ) RLock () +type 4 * +type 5 "sync.Locker" +type 6 interface { Lock (); Unlock (); } +type 7 struct { .sync.w ; .sync.writerSem ; .sync.readerSem ; .sync.readerCount ; .sync.readerWait ; } +type 8 "sync.Mutex" + func (m ) Unlock () + func (m ) Lock () +type 9 * +type 10 struct { .sync.state ; .sync.sema ; } +type 11 [517 ] +type 12 struct { Count ; NumBytes ; Last ; } +checksum 199DCF6D3EE2FCF39F715B4E42B5F87F5B15D3AF -- 2.48.1