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/compile: internal compiler error: treecopy Name, when using go test -race #12225

Closed
tsuna opened this issue Aug 20, 2015 · 7 comments
Closed

Comments

@tsuna
Copy link
Contributor

tsuna commented Aug 20, 2015

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

go version go1.5 darwin/amd64

What operating system and processor architecture are you using?

OS X 10.9.5, Intel

What did you do?

Run go build -race on this file:

package foo

import "unsafe"

func ice() {
    _ = *(*int)(unsafe.Pointer(&[]byte("")[0]))
}

It doesn't matter what's passed to []byte(...), but it seems to matter that it be constructed from a string, not as a literal byte slice (i.e. not []byte{...}).

What did you expect to see?

At best a proper compiler error (although I'm not sure why this could be rejected by the compiler), otherwise a runtime crash.

What did you see instead?
# command-line-arguments
treecopy [0x820b98ea0]
.   INDREG-SP a(true) l(6) x(0+0) tc(1) PTR64-*[32]byte
ice.go:6: internal compiler error: treecopy Name
@bradfitz
Copy link
Contributor

/cc @dvyukov @josharian

@ianlancetaylor ianlancetaylor modified the milestones: Go1.5.2, Go1.5.1 Sep 8, 2015
@tsuna
Copy link
Contributor Author

tsuna commented Oct 31, 2015

@dvyukov any known workaround to alter the code and achieve the same thing without tripping on this bug?

@dvyukov
Copy link
Member

dvyukov commented Oct 31, 2015

@tsuna This seems to work:

func ice() {
    x := []byte("")
    _ = *(*int)(unsafe.Pointer(&x[0]))
}

@dvyukov
Copy link
Member

dvyukov commented Nov 2, 2015

git blame points to:

4fdd53680c0c63d10a8c9c155f6df6e3b1e08367 is the first bad commit
commit 4fdd53680c0c63d10a8c9c155f6df6e3b1e08367
Author: Russ Cox <rsc@golang.org>
Date:   Tue May 26 22:19:27 2015 -0400

    cmd/compile: move Node.Defn to Node.Name.Defn

    $ sizeof -p cmd/compile/internal/gc Node
    Node 256
    $

    Change-Id: I89ac8bbe077664aa076092bfd096947e84c0624c
    Reviewed-on: https://go-review.googlesource.com/10523
    Reviewed-by: Ian Lance Taylor <iant@golang.org>
    Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>

@ianlancetaylor @josharian

@gopherbot
Copy link

CL https://golang.org/cl/16938 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/17034 mentions this issue.

@rsc rsc closed this as completed in 8b1b81f Nov 19, 2015
@gopherbot
Copy link

CL https://golang.org/cl/17125 mentions this issue.

rsc added a commit that referenced this issue Nov 23, 2015
…r containing string->[]byte conversion

The assumption is that there are no nested function calls in complex expressions.
For the most part that assumption is true. It wasn't for these calls inserted during walk.
Fix that.

I looked through all the calls to mkcall in walk and these were the only cases
that emitted calls, that could be part of larger expressions (like not delete),
and that were not already handled.

Fixes #12225.

Change-Id: Iad380683fe2e054d480e7ae4e8faf1078cdd744c
Reviewed-on: https://go-review.googlesource.com/17034
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-on: https://go-review.googlesource.com/17125
mwhudson added a commit to mwhudson/go that referenced this issue Jan 4, 2016
I don't understand how this is linked to the behaviour seen in the bug, but it
feels like the right thing to do.

Fixes golang#12225

Change-Id: Id4a9d8e957e6dcfb7750bdc18363125e6dc020e7
@golang golang locked and limited conversation to collaborators Nov 27, 2016
@rsc rsc removed their assignment 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

6 participants