diff options
author | Jakob Unterwurzacher | 2022-08-28 20:31:27 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2022-08-28 20:31:27 +0200 |
commit | a55b3cc15a6d9bce116a90f33df4bc99d9dd6a10 (patch) | |
tree | 5172278bece45cf031ee942267aaa06f131f2904 /tests/matrix/concurrency_test.go | |
parent | 59165f0f53193f596741b1bc15ade64cb43910ef (diff) |
tests/matrix: fix data race in TestConcurrentReadWrite
Fixes https://github.com/golang/go/issues/54715
Output was:
$ go test ./tests/matrix -run TestConcurrentReadWrite -race
test_helpers: warning: testParentDir "/tmp/gocryptfs-test-parent-1026" does not reside on ext4, we will miss failures caused by ino reuse
PASS
PASS
==================
WARNING: DATA RACE
Write at 0x00c00038a0e0 by goroutine 63:
runtime.racewriterange()
<autogenerated>:1 +0x29
internal/poll.(*FD).Pread()
/usr/local/go/src/internal/poll/fd_unix.go:193 +0x169
os.(*File).pread()
/usr/local/go/src/os/file_posix.go:40 +0x335
os.(*File).ReadAt()
/usr/local/go/src/os/file.go:136 +0x2de
github.com/rfjakob/gocryptfs/v2/tests/matrix.TestConcurrentReadWrite.func1()
/home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/matrix/concurrency_test.go:40 +0x14b
Previous write at 0x00c00038a0e0 by goroutine 61:
runtime.racewriterange()
<autogenerated>:1 +0x29
internal/poll.(*FD).Pread()
/usr/local/go/src/internal/poll/fd_unix.go:193 +0x169
os.(*File).pread()
/usr/local/go/src/os/file_posix.go:40 +0x335
os.(*File).ReadAt()
/usr/local/go/src/os/file.go:136 +0x2de
github.com/rfjakob/gocryptfs/v2/tests/matrix.TestConcurrentReadWrite.func1()
/home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/matrix/concurrency_test.go:40 +0x14b
Goroutine 63 (running) created at:
github.com/rfjakob/gocryptfs/v2/tests/matrix.TestConcurrentReadWrite()
/home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/matrix/concurrency_test.go:34 +0x31d
testing.tRunner()
/usr/local/go/src/testing/testing.go:1446 +0x216
testing.(*T).Run.func1()
/usr/local/go/src/testing/testing.go:1493 +0x47
Goroutine 61 (running) created at:
github.com/rfjakob/gocryptfs/v2/tests/matrix.TestConcurrentReadWrite()
/home/jakob/go/src/github.com/rfjakob/gocryptfs/tests/matrix/concurrency_test.go:34 +0x31d
testing.tRunner()
/usr/local/go/src/testing/testing.go:1446 +0x216
testing.(*T).Run.func1()
/usr/local/go/src/testing/testing.go:1493 +0x47
==================
--- FAIL: TestConcurrentReadWrite (0.03s)
testing.go:1319: race detected during execution of test
FAIL
TestMain: matrix[2] = matrix.testcaseMatrix{plaintextnames:false, openssl:"false", aessiv:false, raw64:false, extraArgs:[]string(nil)} failed
FAIL github.com/rfjakob/gocryptfs/v2/tests/matrix 0.170s
FAIL
Diffstat (limited to 'tests/matrix/concurrency_test.go')
-rw-r--r-- | tests/matrix/concurrency_test.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/matrix/concurrency_test.go b/tests/matrix/concurrency_test.go index d824316..4f060ab 100644 --- a/tests/matrix/concurrency_test.go +++ b/tests/matrix/concurrency_test.go @@ -24,7 +24,6 @@ func TestConcurrentReadWrite(t *testing.T) { } else { f.Close() } - buf := make([]byte, 100) content := []byte("1234567890") threads := 10 loops := 30 @@ -32,6 +31,7 @@ func TestConcurrentReadWrite(t *testing.T) { // Reader thread wg.Add(1) go func() { + buf := make([]byte, 100) fRd, err := os.Open(fn) if err != nil { log.Fatal(err) |