-
Notifications
You must be signed in to change notification settings - Fork 18k
test: go run run.go -linkshared fails #16590
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
Comments
Simple repro
Build with
Works fine without the linkshared. I suspect the problem is in the |
Oh, that's pretty bad :( |
Yes, type switches no worky. I'm going to mark as 1.7. |
I'll take a look tomorrow. There was a similar problem early in the 1.7 cycle where the type is defined in one module and used from another, though I don't know why it would be showing up only for GOARCH=386 now. |
It's not just showing up on 386, it happens on amd64 too. |
(Dumping info on this bug as I find it.) To confirm this is a problem with interface types used across modules:
A standard build prints |
The -linkshared program above has two different *_type values for The runtime requires there be a single *_type for each type, and for multi-module programs the initialization in runtime.typelinksinit should de-duplicate the *_type instances. In this case it's not because these types have different package names: one is "main" and the other is "fmt", so runtime.typesEqual is returning false. Package names are used on these types so that package p2 cannot implement an unexported interface method from package p1. That reasoning does not apply to exported method names, and so the smallest fix to this is to ignore package names on exported function types in runtime.typesEqual. I'm not sure if this is a general fix, still pondering. Fortunately all of this code is guarded behind |
Actually, the bug is not in It's something to do with the That is, the following (absurd) patch fixes the example programs above:
|
I don't see any obvious codegen bugs in the reflect.typeOff method. @randall77 is there any reason why a mapaccess from additab could be a problem? I can replace the data structure with a sorted slice and binary search to fix this, but it would be nice to know why this is broken. |
Stupid questions: data race? If you use comma ok during map access, what does ok say? |
The map is built in typelinksinit and not written to again, so I believe a data race is out. With the patch:
then Keith's test program above prints
|
I don't see any reason why mapaccess would fail there. Any chance there is more than one copy of the runtime package around? That would screw with hash functions. |
...or maybe you build the map before the init function in alg.go? That would make it fail. |
@randall77 that's it, typelinksinit runs before alg.go init. Thanks. I'll send a CL in a bit. |
I think the fix to this (https://golang.org/cl/25469) calls for RC6. |
@crawshaw Sadly, I agree. I suggest that we wait until Monday to cut RC6, in the hopes that any more latent bugs will shake out before then. |
Thanks so much for fixing this, and sorry for finding it so late! |
Is this a regression from 1.6? |
Yes it is (or was, I guess, now it's fixed) |
When compiling with -buildmode=shared, a map[int32]*_type is created for each extra module mapping duplicate types back to a canonical object. This is done in the function typelinksinit, which is called before the init function that sets up the hash functions for the map implementation. The result is typemap becomes unusable after runtime initialization. The fix in this CL is to move algorithm init before typelinksinit in the runtime setup process. (For 1.8, we may want to turn typemap into a sorted slice of types and use binary search.) Manually tested on GOOS=linux with: GOHOSTARCH=386 GOARCH=386 ./make.bash && \ go install -buildmode=shared std && \ cd ../test && \ go run run.go -linkshared Fixes golang#16590 Change-Id: Idc08c50cc70d20028276fbf564509d2cd5405210 Reviewed-on: https://go-review.googlesource.com/25469 Run-TryBot: David Crawshaw <[email protected]> Reviewed-by: Keith Randall <[email protected]>
Please answer these questions before submitting your issue. Thanks!
go version
)?go version devel +50edddb Tue Aug 2 21:31:58 2016 +0000 linux/386
go env
)?Ubuntu 16.04, not that I expect it matters.
everything passing
(and 'goprint' hangs and has to be killed)
This is a regression from 1.6 but too late to fix for release. I'll patch it in Ubuntu if I have to :-)
The text was updated successfully, but these errors were encountered: