getDirectoryContents blow its stack in a huge directory
Once a directory has around 2 million files in it, a lack of an accumulator in getDirectoryContents (unix version only; windows already has an acc) causes it to blow the stack:
joey@darkstar:‾/src/git-annex>cat test.hs
import System.Directory
main = do
l <- getDirectoryContents "/tmp/big"
print (null l)
joey@darkstar:‾/src/git-annex>ghc --make -O2 test
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
joey@darkstar:‾/src/git-annex>./test
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize -RTS' to increase it.
I suggest the attached patch.
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/directory |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |