Comments (6)
Invoked from Cabal:
$ git grep "getDirectoryContents "
Cabal/Distribution/PackageDescription/Check.hs: getDirectoryContents = System.Directory.getDirectoryContents . relative,
Cabal/Distribution/PackageDescription/Check.hs: getDirectoryContents :: FilePath -> m [FilePath],
Cabal/Distribution/PackageDescription/Check.hs: files <- getDirectoryContents ops dir
Cabal/Distribution/Simple/GHC/Internal.hs: objss <- mapM getDirectoryContents dirs
Cabal/Distribution/Simple/LHC.hs: objss <- mapM getDirectoryContents dirs
Cabal/Distribution/Simple/Test.hs: getDirectoryContents testLogDir
Cabal/Distribution/Simple/UHC.hs: mapM (\ d -> getDirectoryContents d >>= filterM (isPkgDir (display compilerid) d))
Cabal/Distribution/Simple/Utils.hs: (files, dirs') <- collect [] [] =<< getDirectoryContents (topdir </> dir)
Cabal/Distribution/Simple/Utils.hs: files <- getDirectoryContents (dir </> dir')
Cabal/Distribution/Simple/Utils.hs: = do files <- getDirectoryContents dir
Cabal/Distribution/Simple/Utils.hs: files <- getDirectoryContents dir
from unix.
From the man page on the readdir
syscall on Linux;
EINVAL Result buffer is too small.
But this is on OSX, not sure if it's the same there.
I'm not sure how to look up when readdir()
should return EINVAL
on OSX. Their man page doesn't list any error codes.. According to https://apple.stackexchange.com/questions/239484/does-apple-provide-a-web-site-with-content-of-man-pages-for-the-command-line-c
Many of the Apple man pages do not keep up with the actual program options
Can we obtain the source code of the current version of readdir()
in OSX?
Also, I found this golang commit from 2 years ago that says:
On OS X 10.10 Yosemite, if you have a directory that can be returned
in a single getdirentries64 call (for example, a directory with one file),
and you read from the directory at EOF twice, you get EOF both times:
fd = open("dir")
getdirentries64(fd) returns data
getdirentries64(fd) returns 0 (EOF)
getdirentries64(fd) returns 0 (EOF)
But if you remove the file in the middle between the two calls, the
second call returns an error instead.
fd = open("dir")
getdirentries64(fd) returns data
getdirentries64(fd) returns 0 (EOF)
remove("dir/file")
getdirentries64(fd) returns ENOENT/EINVAL
Whether you get ENOENT or EINVAL depends on exactly what was
in the directory. It is deterministic, just data-dependent.
This only happens in small directories. A directory containing more data
than fits in a 4k getdirentries64 call will return EOF correctly.
(It's not clear if the criteria is that the directory be split across multiple
getdirentries64 calls or that it be split across multiple file system blocks.)
So it sounds like it's an OSX bug introduced in 10.10.
Further
C program reproducing the issue, also at http://swtch.com/~rsc/readdirbug.c:
@domenkozar Could you try this C program they mention?
At the end they write
I filed Apple Bug 17978656.
But apparently Apple bugs aren't public? Very useful :/
from unix.
The bug happens on macOS 10.12 (xcode 8.3) so it's still present. I can't try the C program on travis-ci easily, but I'll test in another Sierra box.
from unix.
Is this still an issue with current MacOS versions (Monterey or other recent)?
from unix.
Is this still an issue with current MacOS versions (Monterey or other recent)?
Is there a reproducer? (Otherwise I cannot test it.)
The C reproducer quoted above does not indicate a problem on Mac OS Mojave (10.14):
$ gcc readdirbug.c
$ ./a.out
mkdir /tmp/readdirbug
create /tmp/readdirbug/file1
opendir /tmp/readdirbug
readdir: found .
readdir: found ..
readdir: found file1
readdir: EOF
readdir: EOF
readdir: EOF
closedir
opendir /tmp/readdirbug
readdir: found .
readdir: found ..
readdir: found file1
readdir: EOF
rm /tmp/readdirbug/file1
readdir: EOF
readdir: EOF
closedir
ok - everything worked
I'd close this issue...
from unix.
This appears to be no longer applicable.
from unix.
Related Issues (20)
- System.Posix.Semaphore.semThreadWait polls unnecessarily with threaded RTS
- Remove config.sub
- Revitalise System.Posix.DynamicLinker.Module
- Consider paring down the set of output modes HOT 7
- Include GHC 9.4 in CI ? HOT 4
- System library dependencies not documented HOT 3
- Build error with wasm32-wasi: system `wasi' not recognized HOT 11
- `unix-2.8` release for GHC 9.6 HOT 4
- `System.Posix.Env.ByteString.getEnvironment` segfaults on empty environment HOT 5
- NetBSD CI broken HOT 1
- System.Posix.User stopped exporting UserEntry HOT 3
- Should `mkstemp` use `throwErrnoIfMinus1Retry` instead of `throwErrnoIfMinus1`? HOT 3
- Add CI for the JS backend
- getAllGroupEntries fail on rhel8 HOT 23
- Memory unsafety in `withFilePath` in 2.8.2.0 HOT 6
- 2.8.3.0 fails to build on Linux 6.1.62 / glibc 2.35 HOT 2
- Release 2.8.4.0 HOT 10
- waitToSetLock can block but is an unsafe FFI import HOT 6
- Please revise time dependency to < 1.15 HOT 4
- CI: caching is likely broken
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unix.