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

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 24, 2020

@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

@randall77 randall77 commented Sep 24, 2020

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

@gopherbot gopherbot commented Sep 24, 2020

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

@gopherbot gopherbot commented Oct 1, 2020

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

@gopherbot gopherbot closed this 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 added 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.