cmd/cgo: Cgo uint32 -> unsafe.Pointer -> C.ulong conversion fails. #50100
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Was able to reproduce the issue using go1.17.5
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I created a uint32, took it's address, converted the address into an unsafe.Pointer, and then converted the unsafe.Pointer into a *C.ulong. The dereferenced to a C.ulong.
https://gist.github.com/ibd1279/1edb2726f69dbd17f77a8a7657c790b4
What did you expect to see?
I expect to see the value of the uint32 and the C.ulong always be the same.
What did you see instead?
In some number of cases, the value cast through the pointer does not match the value directly cast. Running the attached program on my computer I get his output:
0 iteration : 1053, 0xc00001806c, 0xc00001806c, 0xc00001806c, 4294968349, 1053
2004 iteration : 1053, 0xc000019ffc, 0xc000019ffc, 0xc000019ffc, 5571591916090295325, 1053
Someone else running the same application on a newer M1 mac, using go1.17.3 from homebrew received the following output
0 iteration : 1053, 0xc00001a07c, 0xc00001a07c, 0xc00001a07c, 4294968349, 1053
2000 iteration : 1053, 0xc00001bffc, 0xc00001bffc, 0xc00001bffc, 5571591916090295325, 1053
I was also able to reproduce it on go version go1.13.8 linux/amd64 and go version go1.17.5 linux/amd64
The text was updated successfully, but these errors were encountered: