-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: in generic code, convert iface to type failed with "types from different scopes" #51250
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
At the very least, I don't think "go.shape" should appear in any user visible error messages? I expect the panic message should mention the specific types instead. /cc @danscales @randall77 |
In panicdottypeE, the have and want type descriptors look completely identical (I'm assuming the gcdata is identical too, didn't try to look past the first byte in gdb yet):
Seems like we maybe ended up with identical run-time types that should have been created as the same type from the start or deduplicated. The "types from different scopes" message is really just saying that's the guess, given that there is no other reason why the types aren't the same type (the other possibility printed is that they are in different packages). |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
From what i understand, and the "bypass" branch i've put to my repo, it seems that in a way ( i may be completely wrong, i don't have your understanding of the go runtime 😁 ) the error message is relevant :
in the first case, the type was created inside the package ( namely Once i move the type in another package, the issue disappear ( as you can see in the I hope i was clear enough and i can help 🥲 |
Looks like we have two different itabs representing the same type/interface combo. The itabs are almost identical. They have the same name according to the linker, and all their fields are the same except the hash field. Because the has field is different, the linker doesn't deduplicate like we would normally expect. The types have different hashes, because one time they are computed as the hash of:
or
I think the latter is the right thing to be hashing. Not sure how we get to the former. I think it has something to do with the |
Hm, looks like when compiling |
Change https://go.dev/cl/387974 mentions this issue: |
What is the status of the CL linked to this issue? It is a release blocker and we are working our way to a release. |
There is a CL that fixes this issue. I'm investigating a possibly better fix, should know one way or another by EOD. |
Change https://go.dev/cl/389474 mentions this issue: |
Reopening for cherry-picking into 1.18 release branch. |
Change https://go.dev/cl/390017 mentions this issue: |
…s in type hash This CL is a bit overkill, but it is pretty safe for 1.18. We'll want to revisit for 1.19 so we can avoid the hash collisions between types, e.g. G[int] and G[float64], that will cause some slowdowns (but not incorrect behavior). Thanks Cherry for the simple idea. Fixes #51250 Change-Id: I68130e09ba68e7cc35687bc623f63547bc552867 Reviewed-on: https://go-review.googlesource.com/c/go/+/389474 Trust: Keith Randall <[email protected]> Run-TryBot: Keith Randall <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> (cherry picked from commit d367205) Reviewed-on: https://go-review.googlesource.com/c/go/+/390017 Trust: Dmitri Shuralyov <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]> Reviewed-by: Keith Randall <[email protected]>
Cherry-picked to 1.18 release branch via CL 390017, closing. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
What did you do?
Using generics and interface conversion, i get the following error at runtime :
To check the code, here it is with instruction to replicate : https://github.com/rguilmont/types-from-different-scopes-issue
What did you expect to see?
Thanks !
The text was updated successfully, but these errors were encountered: