Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe Read panic with slice bounds out of range #623

Closed
Prnyself opened this issue Jul 7, 2021 · 2 comments
Closed

Pipe Read panic with slice bounds out of range #623

Prnyself opened this issue Jul 7, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Prnyself
Copy link
Member

Prnyself commented Jul 7, 2021

When I Read and Write concurrently by PipeReader and PipeWriter, I got this panic.

panic: runtime error: slice bounds out of range [:147404] with capacity 65536

goroutine 244 [running]:
github.com/beyondstorage/go-storage/v4/pkg/iowrap.(*PipeReader).Read(0xc0001ea238, 0xc00b510000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
	/Users/lance/go/pkg/mod/github.com/beyondstorage/go-storage/[email protected]/pkg/iowrap/pipe.go:89 +0x28f
io.(*LimitedReader).Read(0xc00074e9f0, 0xc00b510000, 0x8000, 0x8000, 0x3fcc, 0x0, 0x0)
	/usr/local/go/src/io/io.go:473 +0x63
io.copyBuffer(0x531fb40, 0xc0004a16e0, 0x531d140, 0xc00074e9f0, 0xc00b510000, 0x8000, 0x8000, 0x0, 0x0, 0xdb8fdc8)
	/usr/local/go/src/io/io.go:423 +0x12c
io.Copy(...)

This panic can be simply reproducted by code below, with a source file size bigger than 65536:

	r, w := iowrap.Pipe()

	go func() {
		_, err := src.Read(arg.SrcPath, w)
		if err != nil {
			logger.Error("src read failed", zap.Error(err))
		}
	}()

	_, err := dst.Write(arg.DstPath, r, arg.Size)
	if err != nil {
		logger.Error("write single file failed", zap.Error(err))
		return err
	}

However, the range of slice is different every time.

@Prnyself Prnyself added the bug Something isn't working label Jul 7, 2021
@Xuanwo Xuanwo self-assigned this Jul 7, 2021
@Xuanwo
Copy link
Contributor

Xuanwo commented Jul 7, 2021

I'm investigating this issue, please use io.Pipe() until it is resolved.

@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 29, 2021

We will remove this function in further release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants