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/api: Assembly causes API compatibility check to fail #8425

Closed
gopherbot opened this issue Jul 25, 2014 · 7 comments
Closed

cmd/api: Assembly causes API compatibility check to fail #8425

gopherbot opened this issue Jul 25, 2014 · 7 comments

Comments

@gopherbot
Copy link

by qpingu:

go version go1.3 darwin/amd64

1. Start with a fresh checkout of go.
2. Run all.bash and verify that it successfully builds and passes the compatibility test.
3. Copy pkg/crypto/aes/asm_amd64.s to pkg/crypto/cipher and remove everything but the
include.
4. Run all.bash again:

  # Checking API compatibility.
  Error running API checker: exit status 1
  Go version is "go1.3", ignoring -next /Users/lcurley/go/root/api/next.txt
  2014/07/25 16:11:10 error typechecking package crypto/x509:   /Users/lcurley/go/root/src/pkg/crypto/x509/pem_decrypt.go:49:14: cannot use des.NewCipher (value of type func(key []byte) (cipher.Block, error)) as func(key []byte) (cipher.Block, error) value in struct literal (windows-amd64)
  exit status 1


The inclusion of the assembly file, regardless of the contents, causes the compatibility
check to fail with this bizarre error. The code compiles, passes all tests, and doesn't
change exported methods. I believe it works like expected on Linux but I haven't tested
it in months.
@ianlancetaylor
Copy link
Contributor

Comment 1:

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

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 2:

This is really cool. Simpler reproduction case:
cd $GOROOT/src/cmd/api
go run run.go # everything is fine
touch $GOROOT/src/crypto/cipher/asm_amd64.s
go run run.go # magical error from go/types
2014/09/15 11:20:08 error typechecking package crypto/x509:
/Users/rsc/g/go/src/crypto/x509/pem_decrypt.go:49:14: cannot use des.NewCipher (value of
type func(key []byte) (cipher.Block, error)) as func(key []byte) (cipher.Block, error)
value in struct literal (windows-amd64)
It seems like this has to be a bug in go/types. Somehow it is seeing two different
'cipher' packages, but I can't see how.

Owner changed to @griesemer.

Status changed to Accepted.

@griesemer
Copy link
Contributor

Comment 3:

The error disappears if the goapi pkgCache is disabled: comment out goapi.go:586 .
I'd say this is a bug in the package cache or how its contents are used with go/types
(rather than go/types itself). Still investigating.

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 4:

Looks like amd64 is missing from AllTags coming back from go/build for crypto when you
create that file. Will look at AllTags.

@griesemer
Copy link
Contributor

Comment 5:

Observations so far:
1) The bug is reproducible when considering only
    {GOOS: "darwin", GOARCH: "386"},
    {GOOS: "windows", GOARCH: "amd64"},
as (goapi.go) contexts entries.
2) The pkgCache contents are different depending on whether the asm_amd64.s file is
present or not: If the file is present, the pkgCache contains the keys (among others):
    $GOROOT/src/crypto/cipher
    $GOROOT/src/crypto/cipher,amd64
(otherwise it's just:
    $GOROOT/src/crypto/cipher
)
3) The presence of the assembly file affects the go/build.Package.AllTags list; if the
file is present, the list contains the additional tag "amd64" for the cipher package.
4) This tag list is used to create the respective pkgCache keys (see 2).
For reasons I don't fully understand yet, the type-checker must be using entries from
the $GOROOT/src/crypto/cipher and $GOROOT/src/crypto/cipher,amd64 package at the same
time - while the two packages are identical, the package pointers are not, resulting in
an error.
Possible explanations:
- the goapi.go code assumes that the type-checker can handle packages that are
isomorphic but have different package objects (that's not the case)
- there's a bug in how goapi.go sets up the pkgCache.

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 6:

The pkgCache code is clearly not quite right. If we ever hit this in real code in the
repo, we can pull out the pkgCache. But right now it's cutting 40% of the runtime for
the api check, so I'd like to keep it.
I have not checked, but I think maybe this would go away if there were build tags
present for all possible architectures instead of amd64. The all possible thing is much
more common: you have one file for amd64, one for 386, one for arm. Maybe there's
overlap but you basically never have one for amd64 and nothing for 386/arm, or else
you'd have an incomplete package on those. That can happen in external code maybe but
not in the standard library. Because of that theory, it is possible that we will never
see this in a real standard library package.

Status changed to Unfortunate.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@griesemer
Copy link
Contributor

See #21181 for the cause of this issue.

gopherbot pushed a commit that referenced this issue Oct 5, 2018
The origin tagKey is just dirname if no tags input which will cause
pkgCache missmatch if other imported pkg explicit on GOARCH or GOOS

This CL will add GOOS and GOARCH to tagKey

Fixes #8425
Fixes #21181

Change-Id: Ifc189cf6746d753ad7c7e5bb60621297fc0a4e35
Reviewed-on: https://go-review.googlesource.com/c/138315
Reviewed-by: Robert Griesemer <gri@golang.org>
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