-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: duplicate anonymous interface declarations cause non-determinism #30202
Comments
Change https://golang.org/cl/162240 mentions this issue: |
Thank you for reporting this issue @jellevandenhooff! I shall page some folks about it @josharian @mdempsky @randall77 |
I have a bit of a dream as a follow-up... It would be fantastic if there was some job scraping Github for go packages, build them a couple times, and find packages exhibiting non-deterministic builds. |
I did that in Go 1.9, as part of thoroughly testing concurrent compilation. :) |
@josharian @mdempsky @randall77 sorry to bother you in this issue, but related to #29612 Should 2 anonymous interface in different package go to the same bucket in itable? |
@Gnouc I'm not sure entirely what you are asking. Are you talking about the runtime That table is a hash table. The general rule is that two equal keys must map to the same bucket. Different keys should map to different buckets, but they don't have to. Different keys mapping to the same bucket make the code slower, but not wrong. So ideally two otherwise identical anonymous interfaces in different packages should map to different buckets, but they don't have to. Looking at the code, it seems like they would map to the same bucket, as we use a hash of the string representation of the interface type. Not ideal, but this case probably doesn't happen often enough to warrant doing anything about it. |
@randall77 Thanks for the information. Can you take a look at #29612 when you have time. |
Bisecting #31975, which is a duplicate of this issue, yielded https://go-review.googlesource.com/106796, which was the introduction of the indexed export format. Not a surprise, in retrospect, but good to confirm. Of note: https://go-review.googlesource.com/c/go/+/170037 added anonymous interfaces to the standard library ( |
@randall77 any updates on this? |
@andybons https://golang.org/cl/162240 needs finishing up |
Change https://golang.org/cl/183852 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
This happens on both go 1.11.5 and go 1.12rc1
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Similar to #27013 but with the addition of concurrency, the go compiler produces a non-deterministic small.a output when running on the following minimized test program.
To demonstrate:
What did you expect to see?
The go compiler produces the same output each time it is run, since it receives the same inputs.
The little script above should only see one hash from the 20
small.a
files.What did you see instead?
The go compiler produces non-deterministic output
Notes
This issue is related to #27013. The fix for that issue (https://go-review.googlesource.com/c/go/+/129515/) does not work for concurrent builds. It imposes an ordering
based on invocation order of addsignat in src/cmd/compile/internal/gc.go, but that invocation order is non-deterministic.
This problems occurs in the wild in https://github.com/gogo/protobuf/blob/master/types/duration_gogo.go.
The text was updated successfully, but these errors were encountered: