Posix.executeFile having problems with unevaluated argumnets

George Russell ger at tzi.de
Wed Aug 28 08:28:19 EDT 2002


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.  For example it does

echo indefectible $* | mail ger
[the real application] $*

and although the argument should actually be -pipe, what I get mailed is my current PATH, or
something of the sort.  Yes I know it's hard to believe.

Fortunately I have discovered a fix.  If I insert the commands
            deepSeq (args parms) done
            deepSeq (env parms) done
just before doing executeFile (actually they are also outside the exception handler)
everything works swimmingly.  deepSeq is just that helpful utility which forces full
evaluation of its argument, and so this forces full evaluation of the arguments and
parameters.

As I have a fix, and not much spare time, I'm afraid I can't do much to fix this.
But could someone eyeball the code for Posix.executeFile and see if there's something
obviously wrong?



More information about the Glasgow-haskell-bugs mailing list