[Haskell-cafe] Re: Can't figure out source of race condition when using System.Process

Simon Marlow marlowsd at gmail.com
Wed Nov 19 08:43:28 EST 2008


Rafal Kolanski wrote:
> 
> Bryan O'Sullivan wrote:
>> What is the "it" that segfaults? The Haskell program shouldn't, at least.
> 
> The Haskell program. It does so rarely, however, and I'm unable to 
> reproduce it with any consistency, only enough to notice something is 
> wrong with what I've written.
> Upon closer examination my code also returns an error exit code for 
> subprocesses that should've succeeded (pdflatex, but once in a blue moon 
> also pstoedit) similarly rarely.
> 
>> That said, your code for reading from child processes is wrong. You 
>> should read all of a child's output strictly (i.e. hGetContents alone 
>> will not do the trick) before you wait for its exit status. Your 
>> current scheme reverses this order, and there is hence no guarantee 
>> that it will read anything from the defunct child process. There's 
>> some possibility that this might be the cause of your segfault, which 
>> to me would suggest the presence of a bug in the runtime system.
> 
> Well, if there's a bug in the runtime system, I'll try to make sure I 
> can reproduce it before filing a report.

Even if the bug only happens once every few runs, please report it anyway. 
(I've been chasing a lot of bugs like that recently :-).

Cheers,
	Simon


More information about the Haskell-Cafe mailing list