-
Notifications
You must be signed in to change notification settings - Fork 47
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
canonicalizePath hangs when used on a file in an sshfs share (threaded RTS only) #35
Comments
I was not able to reproduce the problem on Linux with GHC 7.10.1. So either it's a problem with SSHFS on Mac, GHC 7.10.2, or that specific SSHFS mount.
I'm somewhat baffled as to how making the call Here is what the code boils down to essentially: import GHC.Foreign as GHC
import GHC.IO.Encoding
import System.Posix.Error
import System.IO
import Foreign
import Foreign.C
import System.FilePath
foreign import ccall unsafe "realpath"
c_realpath :: CString -> CString -> IO CString
main = do
let fpath = "/Users/hamish/haskell/Haxl/haxl.cabal"
enc <- getFileSystemEncoding
GHC.withCString enc fpath $ \pInPath ->
allocaBytes 1024 $ \pOutPath -> do
_ <- throwErrnoPathIfNull "asdf" fpath (c_realpath pInPath pOutPath)
path <- GHC.peekCString enc pOutPath
print (normalise path) |
Seems to happen all the time on OS X. I am using FUSE on OS X.
Yes. It is happening all the time with
I think it might be the latency that is triggering it. The server is in Germany and I am in Vancouver (so probably about 200ms or something).
Log bellow.
My understanding is that
|
If you run it without
Can you check by mounting a closer server? |
Thanks for the It appears to be caused by GHC's periodic timer signals, which repeatedly interrupts the |
Although these functions never return EINTR, signals may still affect these calls. In particular, realpath on Mac OS X contains a retry-if-interrupted loop on statfs64. If the file system is slow (e.g. SSHFS), the call will hang due to the barrage of periodic alarm signals from the GHC runtime. Marking the foreign import as safe appears to silence the alarm signals. We also do this for utimensat as a precautionary measure. Given that these are system calls that manipulate the file system, the performance overhead should be negligible. Fixes haskell#35.
Thanks. I have another issue that might be related. After patching Leksah to use a fixed version of canonicalizePath, it now fails trying to open the file. This time the non threaded RTS also fails. Small test case is:
Non threaded RTS winds up like this...
Threaded RTS like this...
|
Seems to work for both threaded and non threaded RTS |
It would be useful to bring this up with haskell-libraries and/or ghc-devs. The heart of throwErrnoIfMinus1Retry "openFile"
(if non_blocking then c_open f oflags 0o666
else c_safe_open f oflags 0o666) So if |
The issue was discussed on the mailing lists and it looks like using |
Although these functions never return EINTR, signals may still affect these calls. In particular, realpath on Mac OS X contains a retry-if-interrupted loop on statfs64. If the file system is slow (e.g. SSHFS), the call will hang due to the barrage of periodic alarm signals from the GHC runtime. Marking the foreign import as safe appears to silence the alarm signals, although it is not guaranteed [1]. This is the best we can do until [2] gets fixed. We also do this for utimensat as a precautionary measure. Given that these are system calls that manipulate the file system, the performance overhead ought to be negligible. This should alleviate haskell#35 for now. [1] https://mail.haskell.org/pipermail/ghc-devs/2015-September/009770.html [2] https://ghc.haskell.org/trac/ghc/ticket/10840
Refactor and fix test for splitExtension(s)
Fixed upstream: https://phabricator.haskell.org/D2796 |
Tested on GHC 7.10.2 and directory 1.2.2.0 on OS X.
To reproduce this issue first mount a sshfs share (I used a server on a quite high latency link).
Check that the share is working and then compile and run something like this with
--threaded
(where the file haxl.cabal is a file that exists on the server.)
The process hangs.
Changing
to
seems to make the problem go away.
The text was updated successfully, but these errors were encountered: