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: PE linker segfaults in addpersrc when cross-compiling #42384
Comments
When `rsrc.P` is used directly, the array backing the byte slice seems to be at a very odd area in memory which causes the code to later segfault when assigning to the slice (see associated issue for segfault address). This change fixes it so that the linker no longer segfaults when accessing the slice. Fixes golang#42384
Hmm, this actually seems like it may be fixed in master, but is broken in the |
I have a patch which seems to fix things in Go 1.15 (the one GitHub is referencing above). I'd be happy to submit a PR which can be cherry-picked into that release if appropriate. |
CC @thanm @cherrymui |
Thanks for the report. Is the resource symbol written to the binary in another place other than the But I don't understand why the patch above would work. At that point we have cleared many fields from the loader, so I wouldn't expect Maybe we could, if |
When `rsrc.P` is used directly, the array backing the byte slice seems to be at a very odd area in memory which causes the code to later segfault when assigning to the slice (see associated issue for segfault address). This change fixes it so that the linker no longer segfaults when accessing the slice by copying the data to the heap instead of relying on the original data to not have been munmapped underneath us. Fixes golang#42384
@cherrymui thanks for the feedback! Would something like derekparker@220805b be closer to what you have in mind? I've tested it locally and it does indeed fix the segfault. |
@derekparker yes, that is what I thought of. Thanks. (Maybe add a comment explaining the reason when you send a CL.) |
When `rsrc.P` is used directly, the array backing the byte slice seems to be at a very odd area in memory which causes the code to later segfault when assigning to the slice (see associated issue for segfault address). This change fixes it so that the linker no longer segfaults when accessing the slice by copying the data to the heap instead of relying on the original data to not have been munmapped underneath us. Fixes golang#42384
When `rsrc.P` is used directly, the array backing the byte slice seems to be at a very odd area in memory which causes the code to later segfault when assigning to the slice (see associated issue for segfault address). This change fixes it so that the linker no longer segfaults when accessing the slice by copying the data to the heap instead of relying on the original data to not have been munmapped underneath us. Fixes golang#42384
Change https://golang.org/cl/268018 mentions this issue: |
@derekparker Would you be able to confirm that this issue doesn't exist in go1.14 as well. |
@cagedmantis that's correct, I've tested with 1.14.12 which does not exhibit this issue. |
Approved as this is a serious issue without a known workaround. |
Closed by merging aa9b48c to release-branch.go1.15. |
…resource section The resource symbol may have been copied to the mmap'd output buffer. If so, certain conditions can cause that mmap'd output buffer to be munmap'd before we get a chance to use it. To avoid any issues we copy the data to the heap when the resource symbol exists. Fixes #42384 Change-Id: I32ef5420802d7313a3d965b8badfbcfb9f0fba4a GitHub-Last-Rev: 7b0f430 GitHub-Pull-Request: #42427 Reviewed-on: https://go-review.googlesource.com/c/go/+/268018 Run-TryBot: Carlos Amedee <carlos@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Trust: Carlos Amedee <carlos@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
Successful compilation
What did you see instead?
(Ignore the path of the Go source, this reproduces with the Go binaries available for download. The copy I have is built from release-1.15 so I could test changes)
The text was updated successfully, but these errors were encountered: