Navigation Menu

Skip to content
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

go/internal/gccgoimporter: unexpected fixup required with V2 export data #29198

Closed
thanm opened this issue Dec 12, 2018 · 3 comments
Closed

go/internal/gccgoimporter: unexpected fixup required with V2 export data #29198

thanm opened this issue Dec 12, 2018 · 3 comments
Milestone

Comments

@thanm
Copy link
Contributor

thanm commented Dec 12, 2018

What version of Go are you using (go version)?

$ go version
go version devel +0b4bca4654 Fri Nov 30 14:46:17 2018 -0500 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Linux x86_64

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/thanm/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/ssd2/go1"
GOPROXY=""
GORACE=""
GOROOT="/ssd2/go"
GOTMPDIR=""
GOTOOLDIR="/ssd2/go/pkg/tool/linux_amd64"
GCCGO="/ssd/gcc-trunk2/cross/bin/gccgo"
CC="gcc"
CXX="g++"
...

What did you do?

If you compile the attached Go code with an older version of gccgo (not tip) that uses V2 export data, then try to import the export data using go/internal/gccgoimporter, the importer will crash with

panic: import error /tmp/167944616/issueXXX.o:10:1 (byte offset = 917): internal error: unexpected fixup required for issueXXX.FooServer

The code in the importer is written to allow for possible circular type references (a reference to struct type T that takes place somewhere inside the body or definition of T, before T is finalized); this is handled by making a note of the reference and generating a fixup that is applied later. The fixup scheme is not needed for the most recent version of gccgo export data (V3), but it is needed for older verisons such as V1. The example link illustrates a case where it is also needed for V2 export data.

`
package server

import (
"context"
"errors"
)

type A struct {
x int
}

func (a *A) AMethod(y int) *Server {
return nil
}

// FooServer is a server that provides Foo services
type FooServer Server

func (f *FooServer) WriteEvents(ctx context.Context, x int) error {
return errors.New("hey!")
}

type Server struct {
FooServer *FooServer
user string
ctx context.Context
}

func New(sctx context.Context, u string) (*Server, error) {
s := &Server{user: u, ctx: sctx}
s.FooServer = (*FooServer)(s)
return s, nil
}
`

What did you expect to see?

Import succeeded.

What did you see instead?

Import fails with assertion. Here is a representative stack trace (I'm forcing the import by adding this as a test case to the gccgoimporter test suite):

`=== RUN TestObjImporter
--- FAIL: TestObjImporter (0.41s)
importer_test.go:145: gccgo version 9.0
panic: import error /tmp/542355319/issueXXX.o:10:1 (byte offset = 917): internal error: unexpected fixup required for issueXXX.FooServer [recovered]
panic: import error /tmp/542355319/issueXXX.o:10:1 (byte offset = 917): internal error: unexpected fixup required for issueXXX.FooServer

goroutine 5 [running]:
testing.tRunner.func1(0xc000154100)
/go/src/testing/testing.go:827 +0x387
panic(0x58c1a0, 0xc000172180)
/go/src/runtime/panic.go:513 +0x1b7
go/internal/gccgoimporter.(*parser).error(0xc000175380, 0x579300, 0xc00018e190)
/go/src/go/internal/gccgoimporter/parser.go:86 +0x21e
go/internal/gccgoimporter.(*parser).errorf(0xc000175380, 0x5b9cd0, 0x30, 0xc0002b0598, 0x1, 0x1)
/go/src/go/internal/gccgoimporter/parser.go:90 +0xbc
go/internal/gccgoimporter.(*parser).parseNamedType(0xc000175380, 0xc0003ce9d0, 0x1, 0x1, 0x8, 0x1)
/go/src/go/internal/gccgoimporter/parser.go:530 +0x663
go/internal/gccgoimporter.(*parser).parseTypeSpec(0xc000175380, 0xc00017c190, 0xc0003ce9d0, 0x1, 0x1, 0xc0003ce9d0, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:794 +0x367
go/internal/gccgoimporter.(*parser).parseTypeAfterAngle(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x10000c0003ce901, 0xc00018e170)
/go/src/go/internal/gccgoimporter/parser.go:903 +0x571
go/internal/gccgoimporter.(*parser).parseType(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x1, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:882 +0x69
go/internal/gccgoimporter.(*parser).parsePointerType(0xc000175380, 0xc00017c190, 0xc0003ce9b0, 0x1, 0x1, 0x1, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:785 +0x168
go/internal/gccgoimporter.(*parser).parseTypeSpec(0xc000175380, 0xc00017c190, 0xc0003ce9b0, 0x1, 0x1, 0xc0003ce9b0, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:812 +0x434
go/internal/gccgoimporter.(*parser).parseTypeAfterAngle(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0xc0003ce9a0, 0x9)
/go/src/go/internal/gccgoimporter/parser.go:903 +0x571
go/internal/gccgoimporter.(*parser).parseType(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x6, 0x60)
/go/src/go/internal/gccgoimporter/parser.go:882 +0x69
go/internal/gccgoimporter.(*parser).parseField(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x1)
/go/src/go/internal/gccgoimporter/parser.go:241 +0x78
go/internal/gccgoimporter.(*parser).parseStructType(0xc000175380, 0xc00017c190, 0xc0003ce978, 0x1, 0x1, 0x1, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:665 +0x166
go/internal/gccgoimporter.(*parser).parseTypeSpec(0xc000175380, 0xc00017c190, 0xc0003ce978, 0x1, 0x1, 0xc0003ce978, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:805 +0x2b9
go/internal/gccgoimporter.(*parser).parseTypeAfterAngle(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x6, 0xc0003ce959)
/go/src/go/internal/gccgoimporter/parser.go:903 +0x571
go/internal/gccgoimporter.(*parser).parseType(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x1, 0x8)
/go/src/go/internal/gccgoimporter/parser.go:882 +0x69
go/internal/gccgoimporter.(*parser).parseNamedType(0xc000175380, 0xc0003ce960, 0x1, 0x1, 0x8, 0x1)
/go/src/go/internal/gccgoimporter/parser.go:526 +0x17c
go/internal/gccgoimporter.(*parser).parseTypeSpec(0xc000175380, 0xc00017c190, 0xc0003ce960, 0x1, 0x1, 0xc0003ce960, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:794 +0x367
go/internal/gccgoimporter.(*parser).parseTypeAfterAngle(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x10000c0003ce901, 0xc00018e140)
/go/src/go/internal/gccgoimporter/parser.go:903 +0x571
go/internal/gccgoimporter.(*parser).parseType(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x1, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:882 +0x69
go/internal/gccgoimporter.(*parser).parsePointerType(0xc000175380, 0xc00017c190, 0xc0003ce948, 0x1, 0x1, 0x1, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:785 +0x168
go/internal/gccgoimporter.(*parser).parseTypeSpec(0xc000175380, 0xc00017c190, 0xc0003ce948, 0x1, 0x1, 0xc0003ce948, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:812 +0x434
go/internal/gccgoimporter.(*parser).parseTypeAfterAngle(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x1, 0xc000175380)
/go/src/go/internal/gccgoimporter/parser.go:903 +0x571
go/internal/gccgoimporter.(*parser).parseResultList(0xc000175380, 0xc00017c190, 0xc00016c0e0)
/go/src/go/internal/gccgoimporter/parser.go:708 +0x8f
go/internal/gccgoimporter.(*parser).parseNamedType(0xc000175380, 0xc0003ce8c0, 0x1, 0x1, 0x8, 0x1)
/go/src/go/internal/gccgoimporter/parser.go:557 +0x2fc
go/internal/gccgoimporter.(*parser).parseTypeSpec(0xc000175380, 0xc00017c190, 0xc0003ce8c0, 0x1, 0x1, 0xc0003ce8c0, 0x0)
/go/src/go/internal/gccgoimporter/parser.go:794 +0x367
go/internal/gccgoimporter.(*parser).parseTypeAfterAngle(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0x3c, 0xffffffffffffffff)
/go/src/go/internal/gccgoimporter/parser.go:903 +0x571
go/internal/gccgoimporter.(*parser).parseType(0xc000175380, 0xc00017c190, 0x0, 0x0, 0x0, 0xc00017c2d0, 0x100)
/go/src/go/internal/gccgoimporter/parser.go:882 +0x69
go/internal/gccgoimporter.(*parser).parseDirective(0xc000175380)
/go/src/go/internal/gccgoimporter/parser.go:1190 +0x36b
go/internal/gccgoimporter.(*parser).parsePackage(0xc000175380, 0xc000170980)
/go/src/go/internal/gccgoimporter/parser.go:1213 +0x2c
go/internal/gccgoimporter.GetImporter.func1(0xc00016ed20, 0x5b05a9, 0x8, 0x5af36a, 0x1, 0x0, 0x0, 0x0, 0x0)
/go/src/go/internal/gccgoimporter/importer.go:202 +0x3f8
go/internal/gccgoimporter.runImporterTest(0xc000154100, 0xc0000fca50, 0xc0000fca20, 0xc0002b1808)
/go/src/go/internal/gccgoimporter/importer_test.go:25 +0x7b
go/internal/gccgoimporter.TestObjImporter(0xc000154100)
/go/src/go/internal/gccgoimporter/importer_test.go:184 +0xb38
testing.tRunner(0xc000154100, 0x5bba48)
/go/src/testing/testing.go:862 +0xbf
created by testing.(*T).Run
/go/src/testing/testing.go:913 +0x34d
FAIL go/internal/gccgoimporter 0.446s
`

@gopherbot gopherbot added this to the Gccgo milestone Dec 12, 2018
@thanm thanm self-assigned this Dec 12, 2018
@gopherbot
Copy link

Change https://golang.org/cl/153821 mentions this issue: go/internal/gccgoimporter: permit fixups for V2 export data

@gopherbot
Copy link

Change https://golang.org/cl/153831 mentions this issue: go/internal/gccgoimporter: test fix for older gccgo versions

@gopherbot
Copy link

Change https://golang.org/cl/153870 mentions this issue: go/internal/gccgoimporter: test fix for older gccgo versions

gopherbot pushed a commit to golang/tools that referenced this issue Dec 13, 2018
Import test fix https://golang.org/cl/153831 from std lib
version (skips issue29198.go test for older versions of gccgo).

Updates golang/go#29198.

Change-Id: Iddd903068a73a307b1d19d93a7c03b1d00365022
Reviewed-on: https://go-review.googlesource.com/c/153870
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit that referenced this issue Dec 13, 2018
Avoid running the test for issue 29198 if the available copy of gccgo
is too old (needs to support context package). Fixes a failure on the
solaris builder.

Updates #29198.

Change-Id: I2b1b3438f4ac105432f30078fbef78e24f2077cd
Reviewed-on: https://go-review.googlesource.com/c/153831
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@golang golang locked and limited conversation to collaborators Dec 13, 2019
@rsc rsc unassigned thanm Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants