Commit 62c85f1
committed
tarfs: fix a data race condition
Fix a data race condition
WARNING: DATA RACE
Write at 0x00c000178428 by goroutine 27:
github.com/containerd/nydus-snapshotter/pkg/remote/remotes/docker.(*httpReadSeeker).Close()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/remote/remotes/docker/httpreadseeker.go:87 +0x57
github.com/containerd/nydus-snapshotter/pkg/tarfs.(*Manager).blobProcess.func2.1()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/tarfs/tarfs.go:339 +0x48
runtime.deferreturn()
/opt/hostedtoolcache/go/1.20.1/x64/src/runtime/panic.go:476 +0x32
github.com/containerd/nydus-snapshotter/pkg/tarfs.(*Manager).blobProcess.func3()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/tarfs/tarfs.go:394 +0x71
Previous read at 0x00c000178428 by goroutine 40:
github.com/containerd/nydus-snapshotter/pkg/remote/remotes/docker.(*httpReadSeeker).Read()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/remote/remotes/docker/httpreadseeker.go:48 +0x68
bufio.(*Reader).Read()
/opt/hostedtoolcache/go/1.20.1/x64/src/bufio/bufio.go:223 +0x2c3
github.com/containerd/containerd/archive/compression.(*bufferedReader).Read()
/home/runner/go/pkg/mod/github.com/containerd/[email protected]/archive/compression/compression.go:113 +0xa4
io.copyBuffer()
/opt/hostedtoolcache/go/1.20.1/x64/src/io/io.go:427 +0x28d
io.Copy()
/opt/hostedtoolcache/go/1.20.1/x64/src/io/io.go:386 +0x88
os.genericReadFrom()
/opt/hostedtoolcache/go/1.20.1/x64/src/os/file.go:161 +0x34
os.(*File).ReadFrom()
/opt/hostedtoolcache/go/1.20.1/x64/src/os/file.go:155 +0x324
io.copyBuffer()
/opt/hostedtoolcache/go/1.20.1/x64/src/io/io.go:413 +0x1c5
io.Copy()
/opt/hostedtoolcache/go/1.20.1/x64/src/io/io.go:386 +0x84
os/exec.(*Cmd).childStdin.func1()
/opt/hostedtoolcache/go/1.20.1/x64/src/os/exec/exec.go:511 +0x45
os/exec.(*Cmd).Start.func2()
/opt/hostedtoolcache/go/1.20.1/x64/src/os/exec/exec.go:717 +0x42
os/exec.(*Cmd).Start.func3()
/opt/hostedtoolcache/go/1.20.1/x64/src/os/exec/exec.go:729 +0x47
Goroutine 27 (running) created at:
github.com/containerd/nydus-snapshotter/pkg/tarfs.(*Manager).blobProcess()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/tarfs/tarfs.go:393 +0x9dd
github.com/containerd/nydus-snapshotter/pkg/tarfs.(*Manager).PrepareLayer()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/tarfs/tarfs.go:465 +0x444
github.com/containerd/nydus-snapshotter/pkg/tarfs.TestPrepareLayer()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/tarfs/tarfs_test.go:33 +0x188
testing.tRunner()
/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1576 +0x216
testing.(*T).Run.func1()
/opt/hostedtoolcache/go/1.20.1/x64/src/testing/testing.go:1629 +0x47
Goroutine 40 (finished) created at:
os/exec.(*Cmd).Start()
/opt/hostedtoolcache/go/1.20.1/x64/src/os/exec/exec.go:716 +0xf8e
github.com/containerd/containerd/archive/compression.cmdStream()
/home/runner/go/pkg/mod/github.com/containerd/[email protected]/archive/compression/compression.go:284 +0x36f
github.com/containerd/containerd/archive/compression.gzipDecompress()
/home/runner/go/pkg/mod/github.com/containerd/[email protected]/archive/compression/compression.go:272 +0x152
github.com/containerd/containerd/archive/compression.DecompressStream()
/home/runner/go/pkg/mod/github.com/containerd/[email protected]/archive/compression/compression.go:203 +0x3e4
github.com/containerd/nydus-snapshotter/pkg/tarfs.(*Manager).blobProcess.func2()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/tarfs/tarfs.go:341 +0x1b1
github.com/containerd/nydus-snapshotter/pkg/tarfs.(*Manager).blobProcess.func3()
/home/runner/work/nydus-snapshotter/nydus-snapshotter/pkg/tarfs/tarfs.go:394 +0x71
==================
testing.go:1446: race detected during execution of test
Signed-off-by: Jiang Liu <[email protected]>1 parent 9b0521a commit 62c85f1
2 files changed
+29
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
638 | 639 | | |
639 | 640 | | |
640 | 641 | | |
| 642 | + | |
| 643 | + | |
641 | 644 | | |
642 | 645 | | |
643 | 646 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
216 | | - | |
| 217 | + | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
| |||
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
238 | | - | |
| 239 | + | |
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| 244 | + | |
243 | 245 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
248 | 261 | | |
249 | 262 | | |
| 263 | + | |
250 | 264 | | |
251 | | - | |
| 265 | + | |
252 | 266 | | |
253 | 267 | | |
254 | 268 | | |
| |||
338 | 352 | | |
339 | 353 | | |
340 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
341 | 358 | | |
342 | 359 | | |
343 | 360 | | |
| |||
351 | 368 | | |
352 | 369 | | |
353 | 370 | | |
354 | | - | |
| 371 | + | |
355 | 372 | | |
356 | 373 | | |
357 | 374 | | |
| |||
362 | 379 | | |
363 | 380 | | |
364 | 381 | | |
365 | | - | |
| 382 | + | |
366 | 383 | | |
367 | 384 | | |
368 | 385 | | |
| |||
0 commit comments