-
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/cgo: overflow error on int64_t #21708
Comments
This is a serious bug, could be a go1.9.1 candidate.
The problem is that current uint detection is too optimistic. This is the second time I broke in this season, I'm really sorry about that. |
@hirochachacha It's okay, I appreciate the rapid diagnosis. It's easy to stay on go1.8.3 until this is resolved. Thanks for all that you do! |
Change https://golang.org/cl/60510 mentions this issue: |
@reaperhulk Thank you. I sent the fix. I hope that solve the problem |
Reopening for cherry picking for Go1.9.1 |
Change https://golang.org/cl/60810 mentions this issue: |
The approach of https://golang.org/cl/43476 turned out incorrect. The problem is that the sniff introduced by the CL only work for simple expression. And when it fails it fallback to uint64, not int64, which breaks backward compatibility. In this CL, we use DWARF for guessing kind instead. That should be more reliable than previous approach. And importanly, it fallbacks to int64 even if it fails to guess kind. Fixes #21708 Change-Id: I39a18cb2efbe4faa9becdcf53d5ac68dba180d46 Reviewed-on: https://go-review.googlesource.com/60510 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-on: https://go-review.googlesource.com/60810 Reviewed-by: Hiroshi Ioka <[email protected]> Reviewed-by: Chris Broadfoot <[email protected]>
I also tested that the new test in misc/cgo/test works with (int64_t)(0xFFFFFFFFFFFFFFFF) as well as it does with (int64_t)(-1), just in case it didn't. |
Thank you @reaperhulk for reporting it, @hirochachacha for the fix and @rsc for testing and evaluating for the cherry pick. |
Change https://golang.org/cl/70970 mentions this issue: |
CL 70970 OK for Go 1.9.2 (after CL 70849). (Gerrit believes that a cherry-pick of 60810 has already happened on release-branch.go1.9 and will not allow a second. It doesn't appreciate that we wiped that from the Git history. CL 70970 is a straight cherry-pick but with the Change-Id incremented to break the cherry-pick association on Gerrit.) |
The approach of https://golang.org/cl/43476 turned out incorrect. The problem is that the sniff introduced by the CL only work for simple expression. And when it fails it fallback to uint64, not int64, which breaks backward compatibility. In this CL, we use DWARF for guessing kind instead. That should be more reliable than previous approach. And importanly, it fallbacks to int64 even if it fails to guess kind. Fixes #21708 Change-Id: I39a18cb2efbe4faa9becdcf53d5ac68dba180d47 Reviewed-on: https://go-review.googlesource.com/60510 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-on: https://go-review.googlesource.com/60810 Reviewed-by: Hiroshi Ioka <[email protected]> Reviewed-by: Chris Broadfoot <[email protected]> Reviewed-on: https://go-review.googlesource.com/70970 Run-TryBot: Russ Cox <[email protected]>
go1.9.2 has been packaged and includes: The release is posted at golang.org/dl. — golang.org/x/build/cmd/releasebot, Oct 26 21:09:11 UTC |
Under go 1.9 the following code no longer compiles due to an overflow:
./main.go:10: constant 9223372036854775808 overflows C.int64_t
Under go 1.8.3 and below this code compiles and works without error. Obviously 0x8000000000000000 does overflow an int64_t, but it seems like the (int64_t) cast in the C code should already have overflowed it to the value -9223372036854775808 before cgo sees it?
The text was updated successfully, but these errors were encountered: