]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix data race on buildLdflags
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 4 Mar 2014 07:42:02 +0000 (11:42 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 4 Mar 2014 07:42:02 +0000 (11:42 +0400)
Fixes #7438.

LGTM=rsc
R=golang-codereviews
CC=bradfitz, golang-codereviews, iant, rsc
https://golang.org/cl/70420044

src/cmd/go/build.go

index 6c9b9f7e50369638f6daecbc1bbd9551ffa5a76b..bf30be70e4d34ab1c534aae32fd74e4a79c4b46b 100644 (file)
@@ -1714,6 +1714,8 @@ func (gcToolchain) ld(b *builder, p *Package, out string, allactions []*action,
                }
        }
        ldflags := buildLdflags
+       // Limit slice capacity so that concurrent appends do not race on the shared array.
+       ldflags = ldflags[:len(ldflags):len(ldflags)]
        if buildContext.InstallSuffix != "" {
                ldflags = append(ldflags, "-installsuffix", buildContext.InstallSuffix)
        }