]> Cypherpunks repositories - gostls13.git/commit
misc/cgo: fix aliasing bugs in parallel tests that append to shared slices
authorBryan C. Mills <bcmills@google.com>
Mon, 7 Feb 2022 16:33:30 +0000 (11:33 -0500)
committerBryan Mills <bcmills@google.com>
Mon, 7 Feb 2022 17:51:57 +0000 (17:51 +0000)
commit3c4c10ea8c87836a75c4065660c72c0929309dd7
tree13df4a5f05ea46c70cf019165460f59781a8f967
parent867a3d55024b654347fcbc0782a39ecd57d94a27
misc/cgo: fix aliasing bugs in parallel tests that append to shared slices

These tests use a slice to represent the base C compiler command (with
flags). Appending to that slice can cause subtle aliasing bugs, such
as commands that silently corrupt the arguments of other concurrent
commands in parallel tests.

In this change, we explicitly reduce the capacity of the command slice
to force appends to it to always allocate unique new slices.

Fixes #49693

Change-Id: Ide466bf65f12cb6cead3dcba69f513cccb60a160
Reviewed-on: https://go-review.googlesource.com/c/go/+/383754
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
misc/cgo/errors/badsym_test.go
misc/cgo/testcarchive/carchive_test.go
misc/cgo/testcshared/cshared_test.go