[GHC] #9266: getDirectoryContents blow its stack in a huge directory

GHC ghc-devs at haskell.org
Sat Jul 5 16:44:24 UTC 2014


#9266: getDirectoryContents blow its stack in a huge directory
----------------------------------------+----------------------------------
        Reporter:  joeyhess             |            Owner:
            Type:  bug                  |           Status:  new
        Priority:  normal               |        Milestone:
       Component:  libraries/directory  |          Version:  7.6.2
      Resolution:                       |         Keywords:
Operating System:  Linux                |     Architecture:
 Type of failure:  None/Unknown         |  Unknown/Multiple
       Test Case:                       |       Difficulty:  Unknown
        Blocking:                       |       Blocked By:
                                        |  Related Tickets:
----------------------------------------+----------------------------------

Comment (by joeyhess):

 Data.Conduit.Filesystem uses listDirectory to generate a list, and loops
 over it instead. listDirectory comes from system-fileio, and on Windows
 just uses getDirectoryContents. On unix, it essentially re-implements
 getDirectoryContents (unsure why). So, it does not avoid buffering
 [FilePath] in memory.

 But, looking at Data.Conduit.Filesystem, it could certianly be changed to
 use the openDirectory/readDirectory interface prototyped above and avoid
 that problem. Essentially, it would: liftIO (readDirectory h) >>= yield

 In fact, system-fileio has internally a similar openDir/readDir/closeDir,
 although that interface is not exported. So, I think adding that low-level
 interface to directory or somewhere and using it in conduit etc would be a
 good plan.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9266#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list