Bug#575534: [GHC] #4074: Forking not possible with large processes
#4074: Forking not possible with large processes
---------------------------------+------------------------------------------
Reporter: nomeata | Owner: simonmar
Type: bug | Status: new
Priority: normal | Milestone: 6.12.3
Component: Runtime System | Version: 6.12.1
Keywords: | Difficulty: Easy (less than 1 hour)
Os: Linux | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by nomeata):
It is probably hard to find a machine that is both slow enough (CPU wise)
and large enough (memory wise). Here is my test code:
{{{
import qualified Data.ByteString as BS
import Control.Concurrent
import System.Process
main = do
let size = 1000 * 1024 * 1024
bs = BS.replicate size (fromIntegral 5)
BS.minimum bs `seq` return ()
forkIO $ putStrLn "Forked Child"
runCommand "echo hi"
putStrLn "Parent"
BS.minimum bs `seq` return ()
}}}
On my computer, I could trigger the behaviour with a size of
1500*1024*1024:
{{{
vfork() = ? ERESTARTNOINTR (To be
restarted)
--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
rt_sigreturn(0x1a) = 56
clone(child_stack=0xbea,
flags=CLONE_FILES|CLONE_PTRACE|CLONE_VFORK|CLONE_DETACHED|126) = ?
ERESTARTNOINTR (To be restarted)
--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
rt_sigreturn(0x1a) = 56
[..]
}}}
What is interesting is that the program uses vfork() at first. If this
works (because no timer interrupt happens), this call is used:
{{{
vfork(Process 3243 attached
) = 3243
}}}
So there seems to be a fallback logic that tries clone() if vfork() does
not work which kicks in even in the case of ERESTARTNOINTR – probably not
what was intended. But I guess this is independent of our issue.
If you have problem reproducing the error, you can see if at strace at
least shows one or two failed calls due to ERESTARTNOINTR. If so, the
problem is present, the symptoms are just not as bad.
I could not observe this problem with the threaded RTS right now.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4074#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
Reply to: