-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/link: incorrect GC bitmap when global's type is in another shared object #39927
Comments
This happens when the linker is building the gcprog for the globals. It calls There's a secondary issue on ARM64 on master where |
For the secondary issue, CL 215997 made |
Change https://golang.org/cl/240462 mentions this issue: |
Backport candidate? |
This reverts CL 240462. Reason for revert: test fails on PPC64LE. Updates #39927. Change-Id: I4f14fd0c36e604a80ae9f2f86d1e643e28945e93 Reviewed-on: https://go-review.googlesource.com/c/go/+/240616 Reviewed-by: Austin Clements <[email protected]> Reviewed-by: Than McIntosh <[email protected]>
Change https://golang.org/cl/240616 mentions this issue: |
Change reverted because it broke ppc64le. |
@gopherbot, please backport to Go 1.14 and 1.13. |
Backport issue(s) opened: #39955 (for 1.14), #39956 (for 1.13). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/240621 mentions this issue: |
Change https://golang.org/cl/240511 mentions this issue: |
Change https://golang.org/cl/241087 mentions this issue: |
This CL ports CL 234105 and CL 240621 to the old linker, which fix critical bugs (runtime crashes). Updates #39049. Updates #39927. Change-Id: I47afc84349119e320d2e60d64b7188a410835d2b Reviewed-on: https://go-review.googlesource.com/c/go/+/241087 Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Jeremy Faller <[email protected]>
Change https://golang.org/cl/241978 mentions this issue: |
…rary (attempt 2) This is a backport of CL 240621. This is not a clean cherry-pick, as Go 1.15 switches to the new linker while it is still the old linker here. Backporting is straightforward, though. When linking against a Go shared library, when a global variable in the main module has a type defined in the shared library, the linker needs to pull the GC data from the shared library to build the GC program for the global variable. Currently, this fails silently, as the shared library file is closed too early and the read failed (with no error check), causing a zero GC map emitted for the variable, which in turn causes the runtime to treat the variable as pointerless. For now, fix this by keeping the file open. In the future we may want to use mmap to read from the shared library instead. Also add error checking. And fix a (mostly harmless) mistake in size caluculation. Also remove an erroneous condition for ARM64. ARM64 has a special case to get the addend from the relocation on the gcdata field. But that doesn't actually work. And it's no longer necessary to have any special case, since the addend is now applied directly to the gcdata field on ARM64, like on all the other platforms. Fixes #39955. Updates #39927. Change-Id: I01c82422b9f67e872d833336885935bc509bc91b Reviewed-on: https://go-review.googlesource.com/c/go/+/240621 Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Than McIntosh <[email protected]> (cherry picked from commit 7799756) Reviewed-on: https://go-review.googlesource.com/c/go/+/240511 Reviewed-by: Austin Clements <[email protected]>
What version of Go are you using (
go version
)?Also reproduced on master and as far back at Go 1.10.
Does this issue reproduce with the latest release?
Yes.
What did you do?
When linking in shared mode, if the type of a global variable is imported from a package in a different shared object, the global variable is marked as containing no pointers, which can cause the garbage collector to free reachable memory.
Here's an example from @cherrymui:
p.go
main.go
What did you expect to see?
In the example program, the garbage collector should not have freed the objects reachable from
x
, so it should have outputted:What did you see instead?
The garbage collector incorrectly freed the objects reachable from
x
because its type was declared in a package in a different shared object./cc @cherrymui @jeremyfaller @thanm
The text was updated successfully, but these errors were encountered: