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

Directory listing returns incorrect contents for /tmp #28015

Closed
nex3 opened this issue Dec 7, 2016 · 7 comments
Closed

Directory listing returns incorrect contents for /tmp #28015

nex3 opened this issue Dec 7, 2016 · 7 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@nex3
Copy link
Member

nex3 commented Dec 7, 2016

The following program:

import 'dart:io';

main() async {
  print(new Directory("/tmp/").listSync());
  print(await new Directory("/tmp/").list().toList());
}

prints this output for me:

[Directory: '/tmp/uplink-soecks.root.443873550', Directory: '/tmp/.org.chromium.Chromium.qIIf0M']
[Directory: '/tmp/uplink-soecks.root.443873550', Directory: '/tmp/.org.chromium.Chromium.qIIf0M']

I have many more than two entries in my /tmp directory, and I'd expect to see all of them when I list the directory.

I've reproduced this on 1.21.0-dev.9.0 and on stable versions as far back as 1.16.0. I'm using Ubuntu 14.04 LTS.

@nex3 nex3 added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io S1 high type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Dec 7, 2016
nex3 added a commit to dart-lang/glob that referenced this issue Dec 7, 2016
nex3 added a commit to dart-lang/glob that referenced this issue Dec 7, 2016
@whesse
Copy link
Contributor

whesse commented Dec 7, 2016

This is verified on my Linux machine as well.

By moving files around to different directories, and listing using Dart, I have found that the directory list seems to get truncated when it gets to the file
srwxr-x--- 1 whesse eng 0 Dec 7 02:58 chromoting.whesse.ssh_auth_sock
which may be a named pipe, not an actual file.
Removing this file from a directory causes the entire directory to be listed successfully, adding this file to a directory causes that directory listing to be truncated.

I think the C++ native code implementing directory listing for Dart can't handle receiving an entry which isn't the normal file, directory, or symbolic link type, and fails. This failure is turning into an end-of-stream, rather than an error.

If the file type isn't Link, File, or Dir, the code just falls through to line 196, and returns kListDone.

This just needs to be fixed by covering the other cases of sockets, pipes, devices, etc from https://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html

@zanderso
Copy link
Member

zanderso commented Dec 7, 2016

Should the entries that are not regular files be skipped or listed? I would say listed, but I'm not 100% sure that this is consistent with the API docs (which say only "files", "directories", and "links" are listed), so I will punt to @floitschG for confirmation.

@zanderso
Copy link
Member

zanderso commented Dec 7, 2016

@nex3
Copy link
Member Author

nex3 commented Dec 7, 2016

I'd expect them to be listed as Files.

@zanderso
Copy link
Member

zanderso commented Dec 7, 2016

As I said, I would expect so as well, but I'm not going to land a change without the owner of the API weighing in here.

@whesse
Copy link
Contributor

whesse commented Dec 8, 2016

I think Lasse is the library api owner.

@zanderso
Copy link
Member

zanderso commented Dec 8, 2016

@lrhn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants