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

cmd/gc: corrupted export data when inlining a small function with goto #7023

Closed
gopherbot opened this issue Dec 28, 2013 · 3 comments
Closed
Milestone

Comments

@gopherbot
Copy link
Contributor

by ncbray@google.com:

I was playing around with generating go code and found a degenerate goto case that
causes go test to choke.

$ go version
go version go1.2 darwin/amd64


file: junk/bad.go

package junk

func Foo() {
        goto bar
bar:
        // Still reproduces with a "return" here.
        // Does not reproduce with a "Foo()" here.
}


file: junk/bad_test.go

package junk

import (
  "testing"
)

func TestFoo(t *testing.T) {
  Foo()
}


It seems to build fine.

$ go install ./...
$ ls pkg/darwin_amd64/
junk.a


But for some reason chokes the tester.

$ go test ./...
# testmain
/var/folders/jd/0qfhxkbd51qf9pgggpx1xxt40000gn/T/go-build916942264/junk/_test/_testmain.go:9:
syntax error: unexpected <
FAIL    junk [build failed]
@remyoudompheng
Copy link
Contributor

Comment 1:

Export data is corrupted. The bug also exists in Go 1.1.2 so it must be very old.
[remy@mastermind tmp]$ cat z.go
package p
func Foo() {
    goto bar
bar:
}
[remy@mastermind tmp]$ go tool 6g -pack -o z.a z.go
[remy@mastermind tmp]$ ar pf z.a __.PKGDEF
go object linux amd64 devel +c4b7c0824984 Fri Dec 20 23:19:32 2013 -0800 X:none
$$
package p
    import runtime "runtime"
    func @"".Foo () { <node goto>; @"".bar:  }
$$
The fix is a one-liner: https://golang.org/cl/46190043
Affter the patch:
[remy@mastermind tmp]$ go tool 6g -pack -o z.a z.go
[remy@mastermind tmp]$ ar pf z.a __.PKGDEF
go object linux amd64 devel +c4b7c0824984 Fri Dec 20 23:19:32 2013 -0800 X:none
$$
package p
    import runtime "runtime"
    func @"".Foo () { goto @"".bar; @"".bar:  }
$$

Labels changed: added release-go1.3, repo-main.

Status changed to Started.

@davecheney
Copy link
Contributor

Comment 2:

Issue #7061 has been merged into this issue.

@remyoudompheng
Copy link
Contributor

Comment 3:

This issue was closed by revision f739dae.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

4 participants