Skip to content
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

memory corruption on linux/386 with float32 arithmetic, GO386=387, buildmode pie/c-archive [1.15 backport] #41620

Closed
gopherbot opened this issue Sep 24, 2020 · 3 comments
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge release-blocker
Milestone

Comments

@gopherbot
Copy link

@randall77 requested issue #41503 to be considered for backport to the next 1.15 minor release.

@gopherbot Please open backport issues.

@randall77
Copy link
Contributor

This is a compiler bug that causes arbitrary corruption at the intersection of 387, PIE, and float32.
It's been a bug forever (at least 1.10, probably earlier). I request a backport because 387 is going away for 1.16, so there's no path for anyone to get this fix otherwise.

@gopherbot
Copy link
Author

Change https://golang.org/cl/257207 mentions this issue: [release-branch.go1.15] cmd/compile: prevent 387+float32+pie from clobbering registers

@gopherbot
Copy link
Author

Closed by merging fa262e6 to release-branch.go1.15.

@andybons andybons added the CherryPickApproved Used during the release process for point releases label Oct 1, 2020
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Oct 1, 2020
gopherbot pushed a commit that referenced this issue Oct 1, 2020
…bbering registers

The 387 port needs to load a floating-point control word from a
global location to implement float32 arithmetic.
When compiling with -pie, loading that control word clobbers an
integer register. If that register had something important in it, boom.

Fix by using LEAL to materialize the address of the global location
first. LEAL with -pie works because the destination register is
used as the scratch register.

387 support is about to go away (#40255), so this will need to be
backported to have any effect.

No test. I have one, but it requires building with -pie, which
requires cgo. Our testing infrastructure doesn't make that easy.
Not worth it for a port which is about to vanish.

Fixes #41620

Change-Id: I140f9fc8fdce4e74a52c2c046e2bd30ae476d295
Reviewed-on: https://go-review.googlesource.com/c/go/+/257277
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
(cherry picked from commit ea106cc)
Reviewed-on: https://go-review.googlesource.com/c/go/+/257207
claucece pushed a commit to claucece/go that referenced this issue Oct 22, 2020
…bbering registers

The 387 port needs to load a floating-point control word from a
global location to implement float32 arithmetic.
When compiling with -pie, loading that control word clobbers an
integer register. If that register had something important in it, boom.

Fix by using LEAL to materialize the address of the global location
first. LEAL with -pie works because the destination register is
used as the scratch register.

387 support is about to go away (golang#40255), so this will need to be
backported to have any effect.

No test. I have one, but it requires building with -pie, which
requires cgo. Our testing infrastructure doesn't make that easy.
Not worth it for a port which is about to vanish.

Fixes golang#41620

Change-Id: I140f9fc8fdce4e74a52c2c046e2bd30ae476d295
Reviewed-on: https://go-review.googlesource.com/c/go/+/257277
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
(cherry picked from commit ea106cc)
Reviewed-on: https://go-review.googlesource.com/c/go/+/257207
@golang golang locked and limited conversation to collaborators Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases FrozenDueToAge release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants