]> Cypherpunks repositories - gostls13.git/commit
cmd/link: don't unmap output file at error exit
authorCherry Mui <cherryyz@google.com>
Thu, 11 Nov 2021 21:51:08 +0000 (16:51 -0500)
committerCherry Mui <cherryyz@google.com>
Fri, 12 Nov 2021 14:55:44 +0000 (14:55 +0000)
commite9f0381a807d1797e0b5969a29f4a3666a73c9e3
treecde8613e92f7a479a6c555521a37e7e9aa2381db
parent7bed3c7975780cad3c0adcf548d8b2d324a09265
cmd/link: don't unmap output file at error exit

When the link exits on error it currently calls Out.Close, which
will munmap the output buffer and close the file. This may be
called in concurrent phase where other goroutines may be writing
to the output buffer. The munmap can race with the write, causing
it to write to unmapped memory and crash. This CL changes it to
just close the file without unmapping. We're exiting on error
anyway so no need to unmap.

Fixes #47816.

Change-Id: I0e89aca991bdada3d017b7d5c8efc29e46308c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/363357
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/outbuf.go
src/cmd/link/internal/ld/sym.go