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

io: MultiWriter and MultiReader shallow-copy expanded slice varargs (can cause nil-pointer, race conditions, etc) #7809

Closed
gopherbot opened this issue Apr 17, 2014 · 6 comments
Milestone

Comments

@gopherbot
Copy link

by joshlf13:

What does 'go version' print?
go version go1.2 linux/amd64

What steps reproduce the problem?
The easiest problem to demonstrate is the nil-pointer dereference, so I'll give that as
an example.

1. Pass an expanded slice as the varargs to io.MultiReader or io.MultiWriter
2. Set the first element of the slice to nil
3. call Read([]byte{}) or Write([]byte{})

Example on Go Playground: http://play.golang.org/p/Xy4YMB8g4J

What happened?
nil pointer dereference

What should have happened instead?
nothing (method should have returned normally)

Please provide any additional information below.
I have a patch ready if people decide that this is a worthwhile thing to patch. My patch
deep-copies the varargs slice. Original discussion included a suggestion of simply
documenting the behavior (golang-nuts thread:
https://groups.google.com/forum/#!topic/golang-nuts/oZgkDyxqmfQ).
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.3maybe.

@gopherbot
Copy link
Author

Comment 2:

CL https://golang.org/cl/91240045 mentions this issue.

@adg
Copy link
Contributor

adg commented May 8, 2014

Comment 3:

How did you encounter this issue?

@gopherbot
Copy link
Author

Comment 4 by joshlf13:

Honestly I don't remember at this point. I think I may have just been perusing the io
source and noticed it.

@gopherbot
Copy link
Author

Comment 5:

CL https://golang.org/cl/94380043 mentions this issue.

@rsc
Copy link
Contributor

rsc commented May 13, 2014

Comment 6:

This issue was closed by revision 211618c.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants