bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X


From: Pádraig Brady
Subject: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X
Date: Tue, 26 Nov 2013 03:06:00 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 11/25/2013 12:10 AM, Paul Eggert wrote:
> Eric Blake wrote:
>> I bet coreutils' sort has a similar bug
> 
> [Adding bug-coreutils to the CC:.]

Referencing the original coreutils thread from the new bug:
http://lists.gnu.org/archive/html/coreutils/2013-11/msg00083.html

> Coreutils 'sort' runs into this problem only
> if dup2 fails when called from move_fd_or_die
> or if execlp fails.

Right.

> dup2 should never fail when it's called
> the way that 'sort' calls it.  So perhaps
> 'sort' should be simplified to call dup2
> and discard its return value.
> 
> And when execlp fails, 'sort' could _exit
> with a special value, so that the parent
> could report the failure.

For both cases we could _exit(errno),
which the parent would get with waitpid().

Interestingly, currently the parent only
notices an error after stdio eventually issues a write(),
at which point the parent receives SIGPIPE and
exits with status 141 (128 + SIGPIPE).

If instead the parent caught sigchld it
could waitpid() to get the status more directly.
Though there are various gotchas with sigchld handling,
and we'd have to handle the reap() error() calls
outside of the signal handler.  This would also be
the case if we wanted to reap on SIGPIPE.
So at first glance this seems to be a bit overcomplicated
for what it's solving.

How about the attached instead that just uses
a somewhat degraded but simpler error() equivalent.

thanks,
Pádraig.

Attachment: sort-async-safe.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]