Hi!

I have been compiling GHC (from cvs head) in Windows :-)

Fine, I removed usage of sleep in some profiler thingy, so it compiled
and I could continue with build.

But when build get to the point compiling Network.Socket (I think),
hsc2hs barfed permission denied-error (even on repeated attempts) when
(apparently) removing temporary executable it had created.

Well, my fix was to use try $ removeFile foo, slightly unoptimal solution ;-)

Because error was permission problem, there isn't much choice why it
happens - running process in Windows locks executable while there is
an unclosed handle to it.  It is apparent that
libraries/base/System/Internals.hs, line 106 forward
mkProcessHandle :: PHANDLE -> IO ProcessHandle
mkProcessHandle h = do
   ioref <- newIORef h
   mkWeakIORef ioref (c_CloseHandle h)
   return (ProcessHandle ioref)

attaches some sort of finaliser to it (why it's done this way?).

The only sensible solution that springs to mind is to broaden handle
to contain space for exit code for process (or whatever information is
required) and on call to waitProcess/getProcessExitCode gather this
information, close the handle and change the handle to INVALID_HANDLE.
 Also, finaliser would need to ignore such handle, as closing handle
twice is error (possibly also dangerous if handles can rotate, but I
don't know if that is possible).

It'd be nice if this was fixed.  If noone more knowledgeable has time
to poke this, I might give it a go.

I suspect there are more such issues, based on errors I have sometimes
experienced with darcs, maybe it'd need to be tackled by having a
table of weak resources (possibly inside IO?)  that could be run
between actions or on request?

Best regards,
--Esa
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to