> Sorry, I haven't got time to narrow this down to a test case, 
> but here are what I hope are the key factors:
> 
> (1) We start up applications in a child process (forked with 
> Posix.forkProcess)
> by calling Posix.executeFile, wrapped in an Exception.catch 
> handler (to detect errors).
> (2) Both the third (arguments) and fourth argument 
> (environment) of Posix.executeFile
> are non-empty.  The environment at least requires some 
> computation, being obtained
> by prepending another setting to the result of Posix.getEnvironment.
> (3) The second argument of Posix.executeFile is True.
> (4) The executable of the whole compiled Haskell program is 
> pretty big (13.6MB).
>     This may be relevant because the problem I am about to 
> describe developed quite
>     suddenly yesterday afternoon, after I'd made some small 
> changes to completely unrelated
>     areas of the program, and the only explanation I can 
> think of is that in some way
>     the slightly increased size of the executable triggered 
> the problem.
> 
> What happens is that the arguments and environment are 
> somehow garbled.  This is surprising,
> but I have good evidence for it, obtained by putting a small 
> proxy binary between
> Haskell and the environment.

I suspect this is due to a bug in executeFile in the posix library.
Currently, executeFile uses CString.vectorize to make a C array of the
arguments.  CString.vectorize is totally bogus, and will result in
garbage if a GC happens in the middle of marshalling - hence it only
happens for you when the arguments are unevaluated.

Try the enclosed version of executeFile instead, it should solve the
problem.

Cheers,
        Simon

Attachment: execfile.hs
Description: execfile.hs

Reply via email to