Skip to content

System.Directory.canonicalizePath gives bad result

Running ghci on linux with an empty path gives different wrong results each time:

   Prelude> System.Directory.canonicalizePath []
   "\153\229\228]\170\DEL"
   Prelude> System.Directory.canonicalizePath []
   "\160\147\155\\\170\DEL"
   Prelude> System.Directory.canonicalizePath []
   "\136"

As pointed out by geheimdienst on #haskell:

my speculation is this: canonicalizePath calls realpath, which

for "" gives an EINVAL with the result string being undefined.

haskell forgets to check errno and takes the undefined string

This bug exists on 6.12.1 on Debian and 6.12.3 on FreeBSD.

Edited by Ian Lynagh -
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information