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

os: File.Readdir may return nil fileinfo #5960

Closed
hanwen opened this issue Jul 25, 2013 · 5 comments
Closed

os: File.Readdir may return nil fileinfo #5960

hanwen opened this issue Jul 25, 2013 · 5 comments
Milestone

Comments

@hanwen
Copy link
Contributor

hanwen commented Jul 25, 2013

this is with parent: 17384:62d06cccc261 tip

consider 
https://code.google.com/p/go/source/browse/src/pkg/os/file_unix.go#


        fi = make([]FileInfo, len(names))
        for i, filename := range names {
                fip, lerr := Lstat(dirname + filename)
                if err == nil {
                        fi[i] = fip
                        err = lerr
                } else {
                        fi[i] = &fileStat{name: filename}
                }
        }

if lerr != nil, fip may be nil. the docs suggest that the entry for the error should not
be returned.
@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 1:

This code looks wrong in multiple ways. I don't even know what it's trying to do.

Labels changed: added priority-later, go1.2, removed priority-triage.

Status changed to Accepted.

@PieterD
Copy link
Contributor

PieterD commented Aug 1, 2013

Comment 2:

https://code.google.com/p/go/source/browse/src/pkg/os/file_unix.go#152
line 162: if err == nil {
err is always nil, because it was set on line 158 by Readdirnames, which did not fail.
I'm pretty sure this should be:
line 162: if lerr == nil {
I've been trying to think of a test for this, but it depends on constructing a situation
where Readdirnames() returns a name that Lstat can't touch. Playing with permissions
doesn't work (at least not on linux), so maybe filling a directory with a million files,
and start Readdir() while another goroutine starts removing files.
I'll make a CL tonight.

@PieterD
Copy link
Contributor

PieterD commented Aug 1, 2013

Comment 3:

https://golang.org/cl/12261043/
No test, I just can't make Lstat() fail after Readdirnames() didn't.

@davecheney
Copy link
Contributor

Comment 4:

Status changed to Started.

@bradfitz
Copy link
Contributor

bradfitz commented Aug 8, 2013

Comment 5:

This issue was closed by revision bdbd541.

Status changed to Fixed.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 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

6 participants