develooper Front page | perl.perl5.porters | Postings from August 2009

Re: [PATCH] Restore original order of HV free

Thread Previous
From:
Rafael Garcia-Suarez
Date:
August 6, 2009 13:48
Subject:
Re: [PATCH] Restore original order of HV free
Message ID:
b77c1dce0908061348k7e7519deuf38212eb2b59e47c@mail.gmail.com
2009/7/31 Sam Vilain <sam@vilain.net>:
> Sorry. It turns out that the program did indeed have a deadlock
> condition. This destruction order change meant that as all of the open
> FH, "|-" calls unwound as the program exited, they did it in the
> reverse order and this made a real bug in the program happen all the
> time.
>
> So, lessons learned;
>
>  1. don't use open FH, "|-" if you are setting up complicated
>     pipelines of many processes; you can't close the FH in processes
>     which you don't want to be writers on that pipeline, without
>     potentially deadlocking.
>
>  2. filehandles started with open FH, "|prog" etc end up having
>     waitpid() called on them during global destruction, and this too
>     can cause deadlocks for the above reason.
>
>  3. always use pipe() and fork() for IPC :)
>
> I hope that the following doc patch will help transfer my findings to
> people trying to do things like this too.
>
> Subject: [PATCH] pod/perlipc.pod: add some hints on avoiding pipe deadlocks
>
> Tracking down deadlocks when using pipes for IPC can be hard, so put
> even more notes about gotchas in this section of perlipc.

Thanks, applied as c40e8e9bf43b15cbc5725b65e3085fba60a67489

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About