From unknown Sat Jun 21 05:00:19 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#15970 <15970@debbugs.gnu.org> To: bug#15970 <15970@debbugs.gnu.org> Subject: Status: [Bug-tar] Crash in gettext() after fork() on Mac OS X Reply-To: bug#15970 <15970@debbugs.gnu.org> Date: Sat, 21 Jun 2025 12:00:19 +0000 retitle 15970 [Bug-tar] Crash in gettext() after fork() on Mac OS X reassign 15970 coreutils submitter 15970 Paul Eggert severity 15970 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 24 19:10:59 2013 Received: (at submit) by debbugs.gnu.org; 25 Nov 2013 00:10:59 +0000 Received: from localhost ([127.0.0.1]:42979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VkjlS-0007r5-Qc for submit@debbugs.gnu.org; Sun, 24 Nov 2013 19:10:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42693) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VkjlP-0007qq-2k for submit@debbugs.gnu.org; Sun, 24 Nov 2013 19:10:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VkjlA-0002Z8-GS for submit@debbugs.gnu.org; Sun, 24 Nov 2013 19:10:49 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:39890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkjlA-0002Yy-Cs for submit@debbugs.gnu.org; Sun, 24 Nov 2013 19:10:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkjl2-0004Ty-TD for bug-coreutils@gnu.org; Sun, 24 Nov 2013 19:10:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vkjkv-0002YL-9K for bug-coreutils@gnu.org; Sun, 24 Nov 2013 19:10:32 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:54538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vkjkv-0002Vb-3p; Sun, 24 Nov 2013 19:10:25 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 12A5039E8109; Sun, 24 Nov 2013 16:10:17 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P-i+pOLkHx3l; Sun, 24 Nov 2013 16:10:16 -0800 (PST) Received: from [192.168.1.9] (pool-108-0-233-62.lsanca.fios.verizon.net [108.0.233.62]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id AF65F39E8100; Sun, 24 Nov 2013 16:10:16 -0800 (PST) Message-ID: <52929568.6010101@cs.ucla.edu> Date: Sun, 24 Nov 2013 16:10:16 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: bug-tar@gnu.org, bug-coreutils@gnu.org Subject: Re: [Bug-tar] Crash in gettext() after fork() on Mac OS X References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> In-Reply-To: <5290BBFE.7060200@redhat.com> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Eric Blake wrote: > I bet coreutils' sort has a similar bug [Adding bug-coreutils to the CC:.] Coreutils 'sort' runs into this problem only if dup2 fails when called from move_fd_or_die or if execlp fails. 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 25 22:06:13 2013 Received: (at 15970) by debbugs.gnu.org; 26 Nov 2013 03:06:13 +0000 Received: from localhost ([127.0.0.1]:45239 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vl8ya-0004HX-PO for submit@debbugs.gnu.org; Mon, 25 Nov 2013 22:06:13 -0500 Received: from mail4.vodafone.ie ([213.233.128.170]:6341) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vl8yX-0004HH-G8 for 15970@debbugs.gnu.org; Mon, 25 Nov 2013 22:06:11 -0500 Received: from unknown (HELO [192.168.1.79]) ([109.76.216.70]) by mail3.vodafone.ie with ESMTP; 26 Nov 2013 03:06:01 +0000 Message-ID: <52941018.2070909@draigBrady.com> Date: Tue, 26 Nov 2013 03:06:00 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> In-Reply-To: <52929568.6010101@cs.ucla.edu> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------010107010206050106030308" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15970 Cc: 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------010107010206050106030308 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --------------010107010206050106030308 Content-Type: text/x-patch; name="sort-async-safe.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="sort-async-safe.patch" >From ecb2c10001a07f4ef0973353c6d963a068a56eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Tue, 26 Nov 2013 02:47:36 +0000 Subject: [PATCH] sort: avoid issues when issuing diagnostics from child processes * src/sort.c: (async_safe_error): A new limited version of error(), that outputs fixed strings and unconverted errnos to stderr. This is safe to call in the limited context of a signal handler, or in this particular case, between the fork() and exec() of a multithreaded process. (move_fd_or_die): Use the async_safe_error() rather than error(). (maybe_create_temp): Likewise. (open_temp): Likewise. Fixes http://bugs.gnu.org/15970 --- src/sort.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/sort.c b/src/sort.c index bb4e313..9fbb620 100644 --- a/src/sort.c +++ b/src/sort.c @@ -373,6 +373,62 @@ static bool debug; number are present, temp files will be used. */ static unsigned int nmerge = NMERGE_DEFAULT; +/* Used by async_safe_error(), initialized by async_safe_init(). */ +static int async_safe_fileno = 2; + +/* Initialize values unsafe to determine directly within async_safe_error(). */ + +static void +async_safe_init (void) +{ + async_safe_fileno = fileno (stderr); +} + +/* Output an error to stderr using async-signal-safe routines, + and _exit() if STATUS is non zero. + This can be used safely from signal handlers, + and between fork() and exec() of multithreaded processes. + async_safe_init() should be called prior to the first call, + to ensure the correct file descriptor for stderr is used. */ + +static void +async_safe_error (int status, int errnum, const char *errstr) +{ +/* Even if defined HAVE_STRERROR_R, we can't use it, + as it may return a translated string etc. and even if not + may malloc() which is unsafe. We might improve this + by testing for sys_errlist and using that if available. + For now just report the error number. */ + char errbuf[INT_BUFSIZE_BOUND (errnum)]; + + char *p = NULL; + + if (errnum) + { + p = errbuf + sizeof errbuf - 1; + + *--p = '\0'; + + do + *--p = '0' + (errnum % 10); + while ((errnum /= 10) != 0); + } + + ignore_value (write (async_safe_fileno, errstr, strlen (errstr))); + + if (p) + { + ignore_value (write (async_safe_fileno, ": errno ", 8)); + ignore_value (write (async_safe_fileno, p, strlen (p))); + } + + if (p || errnum) + ignore_value (write (async_safe_fileno, "\n", 1)); + + if (status) + _exit (status); +} + /* Report MESSAGE for FILE, then clean up and exit. If FILE is null, it represents standard output. */ @@ -982,8 +1038,9 @@ move_fd_or_die (int oldfd, int newfd) { if (oldfd != newfd) { + /* This should never fail for our usage. */ if (dup2 (oldfd, newfd) < 0) - error (SORT_FAILURE, errno, _("dup2 failed")); + async_safe_error (SORT_FAILURE, errno, "dup2 failed"); close (oldfd); } } @@ -1095,13 +1152,16 @@ maybe_create_temp (FILE **pfp, bool survive_fd_exhaustion) } else if (node->pid == 0) { + /* Being the child of a multithreaded program before exec(), + we're restricted to calling async-signal-safe routines here. */ close (pipefds[1]); move_fd_or_die (tempfd, STDOUT_FILENO); move_fd_or_die (pipefds[0], STDIN_FILENO); - if (execlp (compress_program, compress_program, (char *) NULL) < 0) - error (SORT_FAILURE, errno, _("couldn't execute %s"), - compress_program); + execlp (compress_program, compress_program, (char *) NULL); + + async_safe_error (SORT_FAILURE, errno, + "couldn't execute compress program"); } } @@ -1153,13 +1213,16 @@ open_temp (struct tempnode *temp) break; case 0: + /* Being the child of a multithreaded program before exec(), + we're restricted to calling async-signal-safe routines here. */ close (pipefds[0]); move_fd_or_die (tempfd, STDIN_FILENO); move_fd_or_die (pipefds[1], STDOUT_FILENO); execlp (compress_program, compress_program, "-d", (char *) NULL); - error (SORT_FAILURE, errno, _("couldn't execute %s -d"), - compress_program); + + async_safe_error (SORT_FAILURE, errno, + "couldn't execute compress program (with -d option)"); default: temp->pid = child; @@ -4179,6 +4242,8 @@ main (int argc, char **argv) thousands_sep = -1; } + async_safe_init (); + have_read_stdin = false; inittables (); -- 1.7.7.6 --------------010107010206050106030308-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 25 23:55:40 2013 Received: (at 15970) by debbugs.gnu.org; 26 Nov 2013 04:55:40 +0000 Received: from localhost ([127.0.0.1]:45275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlAgW-00073z-17 for submit@debbugs.gnu.org; Mon, 25 Nov 2013 23:55:40 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:55779) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlAgS-00073j-Gl for 15970@debbugs.gnu.org; Mon, 25 Nov 2013 23:55:37 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 748D639E80FF; Mon, 25 Nov 2013 20:55:30 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HZCrtbolKC8q; Mon, 25 Nov 2013 20:55:30 -0800 (PST) Received: from [192.168.1.9] (pool-108-0-233-62.lsanca.fios.verizon.net [108.0.233.62]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 06FFA39E80F8; Mon, 25 Nov 2013 20:55:30 -0800 (PST) Message-ID: <529429C1.2000207@cs.ucla.edu> Date: Mon, 25 Nov 2013 20:55:29 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> In-Reply-To: <52941018.2070909@draigBrady.com> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 15970 Cc: 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Pádraig Brady wrote: > How about the attached instead that just uses > a somewhat degraded but simpler error() equivalent. That looks safe, though it could be simplified: use inttostr instead of repeating its body, and since !!p == !!errnum there's no need to have those duplicate conditions. Plus, just use STDERR_FILENO rather than fiddling with fileno (stderr), and async_safe_error should be _Noreturn and should unconditionally call _exit. And, I wouldn't bother looking at dup2's return value, any more than we look at close's. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 26 05:54:32 2013 Received: (at 15970) by debbugs.gnu.org; 26 Nov 2013 10:54:32 +0000 Received: from localhost ([127.0.0.1]:45435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlGHn-0007xc-TI for submit@debbugs.gnu.org; Tue, 26 Nov 2013 05:54:32 -0500 Received: from mx-relay16-dus.antispameurope.com ([94.100.134.216]:58325) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlGHf-0007xE-B5 for 15970@debbugs.gnu.org; Tue, 26 Nov 2013 05:54:30 -0500 Received: from pluto.fokus.fraunhofer.de ([195.37.77.164]) by mx-gate16-dus.antispameurope.com; Tue, 26 Nov 2013 11:54:07 +0100 Received: from FEYNMAN.fokus.fraunhofer.de (feynman.fokus.fraunhofer.de [10.147.9.202]) by pluto.fokus.fraunhofer.de (8.14.4/8.14.2) with ESMTP id rAQAropw018646 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Tue, 26 Nov 2013 11:53:51 +0100 (CET) Received: from rigel (10.147.13.100) by FEYNMAN.fokus.fraunhofer.de (10.147.9.202) with Microsoft SMTP Server id 14.3.158.1; Tue, 26 Nov 2013 11:53:50 +0100 Date: Tue, 26 Nov 2013 11:53:50 +0100 From: Joerg Schilling To: , Subject: Re: [Bug-tar] bug#15970: Crash in gettext() after fork() on Mac OS X Message-ID: <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> In-Reply-To: <52941018.2070909@draigBrady.com> User-Agent: nail 11.22 3/20/05 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-KSE-Antivirus-Interceptor-Info: protection disabled X-cloud-security-sender: joerg.schilling@fokus.fraunhofer.de X-cloud-security-recipient: 15970@debbugs.gnu.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mx-gate16-dus with C9B842118046 X-cloud-security-connect: pluto.fokus.fraunhofer.de[195.37.77.164], TLS=, IP=195.37.77.164 X-cloud-security: scantime:3.628 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15970 Cc: 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Are you using "ignore_value" because of the gcc bug that ignores the official method to tell that the return code is ignored intentionally: (void) write(fd, buf, len); Jörg -- EMail:joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js@cs.tu-berlin.de (uni) joerg.schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 26 07:23:27 2013 Received: (at 15970-done) by debbugs.gnu.org; 26 Nov 2013 12:23:28 +0000 Received: from localhost ([127.0.0.1]:45491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlHfq-0001pR-US for submit@debbugs.gnu.org; Tue, 26 Nov 2013 07:23:27 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:41742) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlHfm-0001p8-Un for 15970-done@debbugs.gnu.org; Tue, 26 Nov 2013 07:23:24 -0500 Received: from unknown (HELO [192.168.1.79]) ([109.79.173.97]) by mail2.vodafone.ie with ESMTP; 26 Nov 2013 12:23:16 +0000 Message-ID: <529492B3.6020501@draigBrady.com> Date: Tue, 26 Nov 2013 12:23:15 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <529429C1.2000207@cs.ucla.edu> In-Reply-To: <529429C1.2000207@cs.ucla.edu> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------070003000602060502000909" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15970-done Cc: bug-tar@gnu.org, 15970-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------070003000602060502000909 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/26/2013 04:55 AM, Paul Eggert wrote: > Pádraig Brady wrote: > >> How about the attached instead that just uses >> a somewhat degraded but simpler error() equivalent. > > That looks safe, though it could be simplified: > use inttostr instead of repeating its body, Hah, I was thinking this must be done somewhere else :) > and since !!p == !!errnum there's no need > to have those duplicate conditions. I meant to use (p || errstr), but let's assume errstr is present, so yes we can then remove condition. > Plus, just use STDERR_FILENO rather than > fiddling with fileno (stderr), done > and async_safe_error > should be _Noreturn and should unconditionally call > _exit. fair enough. I changed the name so to async_safe_die() > And, I wouldn't bother looking at dup2's > return value, any more than we look at close's. Updated patch attached. thanks! Pádraig. --------------070003000602060502000909 Content-Type: text/x-patch; name="sort-async-safe.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="sort-async-safe.patch" >From 02ac652957d0e21b0aa285dbcb718d8d60329ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Tue, 26 Nov 2013 02:47:36 +0000 Subject: [PATCH] sort: avoid issues when issuing diagnostics from child processes * src/sort.c: (async_safe_die): A new limited version of error(), that outputs fixed strings and unconverted errnos to stderr. This is safe to call in the limited context of a signal handler, or in this particular case, between the fork() and exec() of a multithreaded process. (move_fd_or_die): Use the async_safe_die() rather than error(). (maybe_create_temp): Likewise. (open_temp): Likewise. Fixes http://bugs.gnu.org/15970 --- src/sort.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/sort.c b/src/sort.c index bb4e313..573d6cb 100644 --- a/src/sort.c +++ b/src/sort.c @@ -373,6 +373,34 @@ static bool debug; number are present, temp files will be used. */ static unsigned int nmerge = NMERGE_DEFAULT; +/* Output an error to stderr using async-signal-safe routines, and _exit(). + This can be used safely from signal handlers, + and between fork() and exec() of multithreaded processes. */ + +static void async_safe_die (int, const char *) ATTRIBUTE_NORETURN; +static void +async_safe_die (int errnum, const char *errstr) +{ + ignore_value (write (STDERR_FILENO, errstr, strlen (errstr))); + + /* Even if defined HAVE_STRERROR_R, we can't use it, + as it may return a translated string etc. and even if not + may malloc() which is unsafe. We might improve this + by testing for sys_errlist and using that if available. + For now just report the error number. */ + if (errnum) + { + char errbuf[INT_BUFSIZE_BOUND (errnum)]; + char *p = inttostr (errnum, errbuf); + ignore_value (write (STDERR_FILENO, ": errno ", 8)); + ignore_value (write (STDERR_FILENO, p, strlen (p))); + } + + ignore_value (write (STDERR_FILENO, "\n", 1)); + + _exit (SORT_FAILURE); +} + /* Report MESSAGE for FILE, then clean up and exit. If FILE is null, it represents standard output. */ @@ -982,8 +1010,8 @@ move_fd_or_die (int oldfd, int newfd) { if (oldfd != newfd) { - if (dup2 (oldfd, newfd) < 0) - error (SORT_FAILURE, errno, _("dup2 failed")); + /* This should never fail for our usage. */ + dup2 (oldfd, newfd); close (oldfd); } } @@ -1095,13 +1123,15 @@ maybe_create_temp (FILE **pfp, bool survive_fd_exhaustion) } else if (node->pid == 0) { + /* Being the child of a multithreaded program before exec(), + we're restricted to calling async-signal-safe routines here. */ close (pipefds[1]); move_fd_or_die (tempfd, STDOUT_FILENO); move_fd_or_die (pipefds[0], STDIN_FILENO); - if (execlp (compress_program, compress_program, (char *) NULL) < 0) - error (SORT_FAILURE, errno, _("couldn't execute %s"), - compress_program); + execlp (compress_program, compress_program, (char *) NULL); + + async_safe_die (errno, "couldn't execute compress program"); } } @@ -1153,13 +1183,15 @@ open_temp (struct tempnode *temp) break; case 0: + /* Being the child of a multithreaded program before exec(), + we're restricted to calling async-signal-safe routines here. */ close (pipefds[0]); move_fd_or_die (tempfd, STDIN_FILENO); move_fd_or_die (pipefds[1], STDOUT_FILENO); execlp (compress_program, compress_program, "-d", (char *) NULL); - error (SORT_FAILURE, errno, _("couldn't execute %s -d"), - compress_program); + + async_safe_die (errno, "couldn't execute compress program (with -d)"); default: temp->pid = child; -- 1.7.7.6 --------------070003000602060502000909-- From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 26 07:35:06 2013 Received: (at 15970) by debbugs.gnu.org; 26 Nov 2013 12:35:06 +0000 Received: from localhost ([127.0.0.1]:45498 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlHr6-0003EA-S1 for submit@debbugs.gnu.org; Tue, 26 Nov 2013 07:35:05 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:53831) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlHr3-0003DY-28 for 15970@debbugs.gnu.org; Tue, 26 Nov 2013 07:35:01 -0500 Received: from unknown (HELO [192.168.1.79]) ([109.79.173.97]) by mail2.vodafone.ie with ESMTP; 26 Nov 2013 12:34:55 +0000 Message-ID: <5294956F.4000102@draigBrady.com> Date: Tue, 26 Nov 2013 12:34:55 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Joerg Schilling Subject: Re: bug#15970: [Bug-tar] bug#15970: Crash in gettext() after fork() on Mac OS X References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> In-Reply-To: <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15970 Cc: eggert@cs.ucla.edu, 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/26/2013 10:53 AM, Joerg Schilling wrote: > > Are you using "ignore_value" because of the gcc bug that ignores the official > method to tell that the return code is ignored intentionally: > > (void) write(fd, buf, len); Right: http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/ignore-value.h;hb=HEAD I thought it marginally cleaner to use that, than to have a goto to just _exit() on write error. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 26 15:34:05 2013 Received: (at 15970) by debbugs.gnu.org; 26 Nov 2013 20:34:05 +0000 Received: from localhost ([127.0.0.1]:46455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlPKd-0008Ho-U4 for submit@debbugs.gnu.org; Tue, 26 Nov 2013 15:34:04 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:41460) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlPKb-0008HJ-B4 for 15970@debbugs.gnu.org; Tue, 26 Nov 2013 15:34:01 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id B256A39E8109; Tue, 26 Nov 2013 12:33:55 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nmJlWnyiZvLQ; Tue, 26 Nov 2013 12:33:55 -0800 (PST) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 6566339E80F8; Tue, 26 Nov 2013 12:33:55 -0800 (PST) Message-ID: <529505B3.8020102@cs.ucla.edu> Date: Tue, 26 Nov 2013 12:33:55 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: 15970@debbugs.gnu.org, P@draigBrady.com Subject: Re: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <529429C1.2000207@cs.ucla.edu> <529492B3.6020501@draigBrady.com> In-Reply-To: <529492B3.6020501@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 15970 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On 11/26/2013 04:23 AM, Pádraig Brady wrote: > Updated patch attached. Thanks, looks good. Hmm, I don't see the patch committed but the bug is marked as closed? From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 26 17:10:03 2013 Received: (at 15970) by debbugs.gnu.org; 26 Nov 2013 22:10:03 +0000 Received: from localhost ([127.0.0.1]:46508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlQpW-0002JG-Vh for submit@debbugs.gnu.org; Tue, 26 Nov 2013 17:10:03 -0500 Received: from mail-pb0-f45.google.com ([209.85.160.45]:56230) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlQpU-0002Ie-Jq for 15970@debbugs.gnu.org; Tue, 26 Nov 2013 17:10:01 -0500 Received: by mail-pb0-f45.google.com with SMTP id rp16so8920619pbb.4 for <15970@debbugs.gnu.org>; Tue, 26 Nov 2013 14:09:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=vQc5WV4/tOmPrmojtqa/UsQAmddDcw3hFyHG6Q7B4G4=; b=ooz1Oh7iFuVJX0neQHUuvXV+DkDuok5kfYmn93Vath2PuvWDNj2Ad5ZUIX4mx01fZj KSwq2MiE6PPqwDMGEcK3QBAwMADsy2glBTLZ5ZN8fAGgvRznxsezYpX+JOPuWflpA6At dblVnT1k9mUZ70A45MU1HcYtOSLs4iOX2AlhaVT3r2zpw0r4OPaWLuYuKM7DwF3tGOHM LL0DineoKu1M/QI9XBzKM1TShjxyOY3vgz3RQuGbXBkR4N1NY9WcVzCvvgiw4MJble7R tcvLxOQPG0z9Fd7SADVJMI3pn0L2c4bLFzCEqUjX4G95AOCaLAXLvuZrCNV4QcTRJnX7 x6NQ== X-Received: by 10.66.186.204 with SMTP id fm12mr5402791pac.189.1385503794716; Tue, 26 Nov 2013 14:09:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.68.6.66 with HTTP; Tue, 26 Nov 2013 14:09:34 -0800 (PST) In-Reply-To: <52941018.2070909@draigBrady.com> References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> From: Jim Meyering Date: Tue, 26 Nov 2013 14:09:34 -0800 X-Google-Sender-Auth: 5kQq45zbdeMJG7emONuTu48fBKI Message-ID: Subject: Re: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X To: =?ISO-8859-1?Q?P=E1draig_Brady?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 15970 Cc: Paul Eggert , 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Hi P=E1draig, Thanks for dealing with that. Your patch looks correct. Did you consider using inttostr in place of that first part of async_safe_e= rror? From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 26 20:26:01 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 01:26:01 +0000 Received: from localhost ([127.0.0.1]:46579 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlTtB-0007CU-A7 for submit@debbugs.gnu.org; Tue, 26 Nov 2013 20:26:01 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:55738) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlTt8-0007CE-Lk for 15970@debbugs.gnu.org; Tue, 26 Nov 2013 20:25:59 -0500 Received: from unknown (HELO [192.168.1.79]) ([109.79.173.97]) by mail2.vodafone.ie with ESMTP; 27 Nov 2013 01:25:52 +0000 Message-ID: <52954A20.6070506@draigBrady.com> Date: Wed, 27 Nov 2013 01:25:52 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15970 Cc: Paul Eggert , 15970@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/26/2013 10:09 PM, Jim Meyering wrote: > Hi Pádraig, > > Thanks for dealing with that. Your patch looks correct. > Did you consider using inttostr in place of that first part of async_safe_error? Paul suggested that too and I've pushed an updated patch now. I'd searched for INTTOSTR without luck, and in my tired state just open coded it meaning to come back and search for the routine :) thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 27 09:39:09 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 14:39:09 +0000 Received: from localhost ([127.0.0.1]:47264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlgGi-0003Q3-Jf for submit@debbugs.gnu.org; Wed, 27 Nov 2013 09:39:08 -0500 Received: from bromo.med.uc.edu ([129.137.3.146]:41568) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlgGe-0003PW-6C for 15970@debbugs.gnu.org; Wed, 27 Nov 2013 09:39:04 -0500 Received: from bromo.med.uc.edu (localhost.localdomain [127.0.0.1]) by bromo.med.uc.edu (Postfix) with ESMTP id 1D103B0045; Wed, 27 Nov 2013 09:38:58 -0500 (EST) Received: (from howarth@localhost) by bromo.med.uc.edu (8.14.3/8.14.3/Submit) id rAREcvFi022895; Wed, 27 Nov 2013 09:38:57 -0500 Date: Wed, 27 Nov 2013 09:38:57 -0500 From: Jack Howarth To: =?iso-8859-1?Q?P=E1draig?= Brady Subject: Re: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X Message-ID: <20131127143857.GA22734@bromo.med.uc.edu> References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52954A20.6070506@draigBrady.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52954A20.6070506@draigBrady.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15970 Cc: Paul Eggert , Jim Meyering , 15970@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On Wed, Nov 27, 2013 at 01:25:52AM +0000, Pádraig Brady wrote: > On 11/26/2013 10:09 PM, Jim Meyering wrote: > > Hi Pádraig, > > > > Thanks for dealing with that. Your patch looks correct. > > Did you consider using inttostr in place of that first part of async_safe_error? > > Paul suggested that too and I've pushed an updated patch now. > I'd searched for INTTOSTR without luck, and in my tired state > just open coded it meaning to come back and search for the routine :) > > thanks, > Pádraig. Pádraig, What revision was the commit? Also was the commit to the tar or gnulib git? I ask because neither's web interface is showing a recent commit for this fix. Thanks in advance so we can test this fix on darwin. Jack > > From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 27 09:57:50 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 14:57:50 +0000 Received: from localhost ([127.0.0.1]:47813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlgYn-0003zS-Qe for submit@debbugs.gnu.org; Wed, 27 Nov 2013 09:57:50 -0500 Received: from mail2.vodafone.ie ([213.233.128.44]:11580) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlgYg-0003zI-O5 for 15970@debbugs.gnu.org; Wed, 27 Nov 2013 09:57:44 -0500 Received: from unknown (HELO [192.168.1.79]) ([109.77.114.67]) by mail2.vodafone.ie with ESMTP; 27 Nov 2013 14:57:35 +0000 Message-ID: <5296085F.8050506@draigBrady.com> Date: Wed, 27 Nov 2013 14:57:35 +0000 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Jack Howarth Subject: Re: bug#15970: [Bug-tar] Crash in gettext() after fork() on Mac OS X References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52954A20.6070506@draigBrady.com> <20131127143857.GA22734@bromo.med.uc.edu> In-Reply-To: <20131127143857.GA22734@bromo.med.uc.edu> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15970 Cc: Paul Eggert , Jim Meyering , 15970@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/27/2013 02:38 PM, Jack Howarth wrote: > On Wed, Nov 27, 2013 at 01:25:52AM +0000, Pádraig Brady wrote: >> On 11/26/2013 10:09 PM, Jim Meyering wrote: >>> Hi Pádraig, >>> >>> Thanks for dealing with that. Your patch looks correct. >>> Did you consider using inttostr in place of that first part of async_safe_error? >> >> Paul suggested that too and I've pushed an updated patch now. >> I'd searched for INTTOSTR without luck, and in my tired state >> just open coded it meaning to come back and search for the routine :) >> >> thanks, >> Pádraig. > > Pádraig, > What revision was the commit? Also was the commit to the tar or gnulib git? I ask > because neither's web interface is showing a recent commit for this fix. Thanks in > advance so we can test this fix on darwin. Sorry there was some crossposting going on. My commit was only precautionary and for coreutils sort: http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commit;h=39e0c9ba thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 27 11:31:10 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 16:31:10 +0000 Received: from localhost ([127.0.0.1]:47894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vli18-0006OW-5o for submit@debbugs.gnu.org; Wed, 27 Nov 2013 11:31:10 -0500 Received: from mx-relay15-dus.antispameurope.com ([94.100.134.215]:38979) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vli15-0006Ny-05 for 15970@debbugs.gnu.org; Wed, 27 Nov 2013 11:31:09 -0500 Received: from pluto.fokus.fraunhofer.de ([195.37.77.164]) by mx-gate15-dus.antispameurope.com; Wed, 27 Nov 2013 17:30:55 +0100 Received: from DIRAC.fokus.fraunhofer.de (dirac.fokus.fraunhofer.de [10.147.9.201]) by pluto.fokus.fraunhofer.de (8.14.4/8.14.2) with ESMTP id rARGUnF8005670 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Wed, 27 Nov 2013 17:30:52 +0100 (CET) Received: from rigel (10.147.13.100) by DIRAC.fokus.fraunhofer.de (10.147.9.201) with Microsoft SMTP Server id 14.3.158.1; Wed, 27 Nov 2013 17:30:48 +0100 Date: Wed, 27 Nov 2013 17:30:49 +0100 From: Joerg Schilling To: Subject: Re: [Bug-tar] bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X Message-ID: <52961e39.FZTibVERBNl2jOgT%Joerg.Schilling@fokus.fraunhofer.de> References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> <5294956F.4000102@draigBrady.com> In-Reply-To: <5294956F.4000102@draigBrady.com> User-Agent: nail 11.22 3/20/05 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-KSE-Antivirus-Interceptor-Info: protection disabled X-cloud-security-sender: joerg.schilling@fokus.fraunhofer.de X-cloud-security-recipient: 15970@debbugs.gnu.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mx-gate15-dus with 37FF02118012 X-cloud-security-connect: pluto.fokus.fraunhofer.de[195.37.77.164], TLS=, IP=195.37.77.164 X-cloud-security: scantime:.7924 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 15970 Cc: eggert@cs.ucla.edu, 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Pádraig Brady wrote: > On 11/26/2013 10:53 AM, Joerg Schilling wrote: > > > > Are you using "ignore_value" because of the gcc bug that ignores the official > > method to tell that the return code is ignored intentionally: > > > > (void) write(fd, buf, len); > > Right: http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/ignore-value.h;hb=HEAD > > I thought it marginally cleaner to use that, > than to have a goto to just _exit() on write error. Do you believe this is the right method to deal with the problem? It will most likely prevent to create enough pressure on the GCC people to fix the current warning problem. Jörg -- EMail:joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js@cs.tu-berlin.de (uni) joerg.schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 27 11:44:19 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 16:44:19 +0000 Received: from localhost ([127.0.0.1]:47906 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VliDr-0006jQ-19 for submit@debbugs.gnu.org; Wed, 27 Nov 2013 11:44:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20350) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VliDo-0006jH-8U for 15970@debbugs.gnu.org; Wed, 27 Nov 2013 11:44:17 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rARGi8N0018931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Nov 2013 11:44:08 -0500 Received: from [10.3.113.9] ([10.3.113.9]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rARGi6bc015251; Wed, 27 Nov 2013 11:44:07 -0500 Message-ID: <52962156.6000202@redhat.com> Date: Wed, 27 Nov 2013 09:44:06 -0700 From: Eric Blake Organization: Red Hat, Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Joerg Schilling , P@draigBrady.com Subject: ignore_value vs (void) [was: [Bug-tar] bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X] References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> <5294956F.4000102@draigBrady.com> <52961e39.FZTibVERBNl2jOgT%Joerg.Schilling@fokus.fraunhofer.de> In-Reply-To: <52961e39.FZTibVERBNl2jOgT%Joerg.Schilling@fokus.fraunhofer.de> X-Enigmail-Version: 1.6 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Pgeb2wp86ULTKcNVjAt3Li8BUvOb91r3O" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 15970 Cc: eggert@cs.ucla.edu, 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Pgeb2wp86ULTKcNVjAt3Li8BUvOb91r3O Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/27/2013 09:30 AM, Joerg Schilling wrote: >>> Are you using "ignore_value" because of the gcc bug that ignores the = official >>> method to tell that the return code is ignored intentionally: >>> >>> (void) write(fd, buf, len); The C standard does not document that '(void) write(...)' is required to avoid diagnostics, so I don't see the gcc behavior as a bug (yes, it's annoying behavior, but that doesn't make it incorrect behavior). > Do you believe this is the right method to deal with the problem? We're already stuck with compilers in the wild where casting to void is insufficient to shut up the compiler warnings, so at this point in time, any GNU code that wants to avoid warnings is better off using gnulib's ignore_value() than a cast to void. At which point, it should not matter what ignore_value() uses under the hood (personally, I PREFER use of ignore_value() - function syntax is easier to read as declaring the intent of what I'm doing than cast syntax, and a coding style that minimizes casts is preferred). > It will most likely prevent to create enough pressure on the GCC people= to fix=20 > the current warning problem. No, I don't think that gnulib's use of ignore_value() is enough pressure to make gcc change their warning behavior. Nor do I care - even if gcc changes behavior, I still plan on using ignore_value() (and let gnulib figure out how to map ignore_value to the most efficient semantics for each compiler it is tested with). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Pgeb2wp86ULTKcNVjAt3Li8BUvOb91r3O Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSliFWAAoJEKeha0olJ0NqMTUH/ixpEXZMEIQmBQCIEd42Znob 4YVDvhA/zEecBfHQGDTdNZY61tCdLO9bqMpMWCN5siSi1W35cVjOOuFWujMM7hV2 aUETeX+CSyDgZyZg8b86hnFaNGV5yYitAbOJuFm9ZkbYHCMu63gpj+7J5potnjiQ ir4fOKC5WJb2b85kAJJup269W6RPAWXtCOJPRjSPhknrYLQHNMu4y7pSDHVuHElu Bcy051x2ZlvbvC7WwkSYFZ8BmvbbcFCjfnWNucE6SNVNTEQudvxqbcJ1eLxFzKM6 auMGepiELgNX38huU1uj5Q6eSa+X765OfjMijFn3q7acSYOot6Lk33Dbpypj6Vc= =fkgM -----END PGP SIGNATURE----- --Pgeb2wp86ULTKcNVjAt3Li8BUvOb91r3O-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 27 11:53:58 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 16:53:58 +0000 Received: from localhost ([127.0.0.1]:47921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VliNB-0006z9-QJ for submit@debbugs.gnu.org; Wed, 27 Nov 2013 11:53:58 -0500 Received: from mx-relay05-dus.antispameurope.com ([94.100.134.205]:54653) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VliN9-0006yu-2P for 15970@debbugs.gnu.org; Wed, 27 Nov 2013 11:53:56 -0500 Received: from pluto.fokus.fraunhofer.de ([195.37.77.164]) by mx-gate05-dus.antispameurope.com; Wed, 27 Nov 2013 17:53:45 +0100 Received: from FEYNMAN.fokus.fraunhofer.de (feynman.fokus.fraunhofer.de [10.147.9.202]) by pluto.fokus.fraunhofer.de (8.14.4/8.14.2) with ESMTP id rARGrhJx006382 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Wed, 27 Nov 2013 17:53:43 +0100 (CET) Received: from rigel (10.147.13.100) by FEYNMAN.fokus.fraunhofer.de (10.147.9.202) with Microsoft SMTP Server id 14.3.158.1; Wed, 27 Nov 2013 17:53:43 +0100 Date: Wed, 27 Nov 2013 17:53:42 +0100 From: Joerg Schilling To: , Subject: Re: ignore_value vs (void) [was: [Bug-tar] bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X] Message-ID: <52962396.9Q85fOMyjHPXe9Wc%Joerg.Schilling@fokus.fraunhofer.de> References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> <5294956F.4000102@draigBrady.com> <52961e39.FZTibVERBNl2jOgT%Joerg.Schilling@fokus.fraunhofer.de> <52962156.6000202@redhat.com> In-Reply-To: <52962156.6000202@redhat.com> User-Agent: nail 11.22 3/20/05 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-KSE-Antivirus-Interceptor-Info: protection disabled X-cloud-security-sender: joerg.schilling@fokus.fraunhofer.de X-cloud-security-recipient: 15970@debbugs.gnu.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mx-gate05-dus with 1F7B610A0029 X-cloud-security-connect: pluto.fokus.fraunhofer.de[195.37.77.164], TLS=, IP=195.37.77.164 X-cloud-security: scantime:.2071 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 15970 Cc: eggert@cs.ucla.edu, 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Eric Blake wrote: > On 11/27/2013 09:30 AM, Joerg Schilling wrote: > >>> Are you using "ignore_value" because of the gcc bug that ignores the official > >>> method to tell that the return code is ignored intentionally: > >>> > >>> (void) write(fd, buf, len); > > The C standard does not document that '(void) write(...)' is required to > avoid diagnostics, so I don't see the gcc behavior as a bug (yes, it's > annoying behavior, but that doesn't make it incorrect behavior). Well, there is a more than 30 year history of lint that causes '(void) write(...)' to be accepted without a warning. Jörg -- EMail:joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js@cs.tu-berlin.de (uni) joerg.schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 27 11:57:19 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 16:57:19 +0000 Received: from localhost ([127.0.0.1]:47927 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VliQQ-00074S-VJ for submit@debbugs.gnu.org; Wed, 27 Nov 2013 11:57:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33827) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VliQN-00074G-Hc for 15970@debbugs.gnu.org; Wed, 27 Nov 2013 11:57:17 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rARGvD6i022980 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Nov 2013 11:57:13 -0500 Received: from [10.3.113.9] ([10.3.113.9]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rARGvCqj014663; Wed, 27 Nov 2013 11:57:12 -0500 Message-ID: <52962468.7070909@redhat.com> Date: Wed, 27 Nov 2013 09:57:12 -0700 From: Eric Blake Organization: Red Hat, Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Joerg Schilling , P@draigBrady.com Subject: Re: ignore_value vs (void) [was: [Bug-tar] bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X] References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> <5294956F.4000102@draigBrady.com> <52961e39.FZTibVERBNl2jOgT%Joerg.Schilling@fokus.fraunhofer.de> <52962156.6000202@redhat.com> <52962396.9Q85fOMyjHPXe9Wc%Joerg.Schilling@fokus.fraunhofer.de> In-Reply-To: <52962396.9Q85fOMyjHPXe9Wc%Joerg.Schilling@fokus.fraunhofer.de> X-Enigmail-Version: 1.6 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ub29PRaue2K1iD7bN1ET0RV2Hv5DROt9u" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 15970 Cc: eggert@cs.ucla.edu, 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ub29PRaue2K1iD7bN1ET0RV2Hv5DROt9u Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/27/2013 09:53 AM, Joerg Schilling wrote: >> The C standard does not document that '(void) write(...)' is required = to >> avoid diagnostics, so I don't see the gcc behavior as a bug (yes, it's= >> annoying behavior, but that doesn't make it incorrect behavior). >=20 > Well, there is a more than 30 year history of lint that causes=20 > '(void) write(...)' to be accepted without a warning. So? Lint is not gcc, and gcc is not lint. Different compilers have different capabilities at producing warnings, and you cannot expect that something that works warning-free on one compiler will remain warning-free on other compilers (even later versions of the same compiler). Warnings are an art form, and not an exact science, precisely because the C standard does not (rather, cannot) specify them. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ub29PRaue2K1iD7bN1ET0RV2Hv5DROt9u Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSliRoAAoJEKeha0olJ0NqMhsH/ik1vwC5LDiW3l/4apfXSuAW axPwARDxSBHTkHBh99vovTnDdEGMOVZ1hp94EwGKG3taswZj6TZEGvTIlDq5QQxE zTOAATXSI/tldRL8gPjYoMBolEhheBUVHnG5d1BvUjBzTUqtlbxWnlsu4iR3QhP/ gtbnF6sGMgY5dooqaGztefJwzpSBunCRd+JlPf+DVCemQM/P3P6N1KNGMEA69ZU4 Ue8U+PuRp2jJIQUbWuWm1YiGKhx2/2m5ZCmO1rR3RRQk5H0U5wxrZhtL3/z4aqkL iRD6Klh7WCO30NJp/zw2fFu2kM4XfxxXhkBcAyKoFEMHYTwWw9T8/+pxP4aMqt4= =sivY -----END PGP SIGNATURE----- --ub29PRaue2K1iD7bN1ET0RV2Hv5DROt9u-- From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 27 12:06:04 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 17:06:04 +0000 Received: from localhost ([127.0.0.1]:47940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VliYu-0007JG-6C for submit@debbugs.gnu.org; Wed, 27 Nov 2013 12:06:04 -0500 Received: from mx-relay18-dus.antispameurope.com ([94.100.134.218]:33076) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VliYo-0007Ih-Ea for 15970@debbugs.gnu.org; Wed, 27 Nov 2013 12:06:02 -0500 Received: from pluto.fokus.fraunhofer.de ([195.37.77.164]) by mx-gate18-dus.antispameurope.com; Wed, 27 Nov 2013 18:05:47 +0100 Received: from FEYNMAN.fokus.fraunhofer.de (feynman.fokus.fraunhofer.de [10.147.9.202]) by pluto.fokus.fraunhofer.de (8.14.4/8.14.2) with ESMTP id rARH5edf006779 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Wed, 27 Nov 2013 18:05:40 +0100 (CET) Received: from rigel (10.147.13.100) by FEYNMAN.fokus.fraunhofer.de (10.147.9.202) with Microsoft SMTP Server id 14.3.158.1; Wed, 27 Nov 2013 18:05:40 +0100 Date: Wed, 27 Nov 2013 18:05:39 +0100 From: Joerg Schilling To: , Subject: Re: ignore_value vs (void) [was: [Bug-tar] bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X] Message-ID: <52962663.juBVzwF6YslFl6IE%Joerg.Schilling@fokus.fraunhofer.de> References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> <5294956F.4000102@draigBrady.com> <52961e39.FZTibVERBNl2jOgT%Joerg.Schilling@fokus.fraunhofer.de> <52962156.6000202@redhat.com> <52962396.9Q85fOMyjHPXe9Wc%Joerg.Schilling@fokus.fraunhofer.de> <52962468.7070909@redhat.com> In-Reply-To: <52962468.7070909@redhat.com> User-Agent: nail 11.22 3/20/05 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-KSE-Antivirus-Interceptor-Info: protection disabled X-cloud-security-sender: joerg.schilling@fokus.fraunhofer.de X-cloud-security-recipient: 15970@debbugs.gnu.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mx-gate18-dus with 456992118014 X-cloud-security-connect: pluto.fokus.fraunhofer.de[195.37.77.164], TLS=, IP=195.37.77.164 X-cloud-security: scantime:1.734 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15970 Cc: eggert@cs.ucla.edu, 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Eric Blake wrote: > On 11/27/2013 09:53 AM, Joerg Schilling wrote: > >> The C standard does not document that '(void) write(...)' is required to > >> avoid diagnostics, so I don't see the gcc behavior as a bug (yes, it's > >> annoying behavior, but that doesn't make it incorrect behavior). > > > > Well, there is a more than 30 year history of lint that causes > > '(void) write(...)' to be accepted without a warning. > > So? Lint is not gcc, and gcc is not lint. Different compilers have > different capabilities at producing warnings, and you cannot expect that > something that works warning-free on one compiler will remain > warning-free on other compilers (even later versions of the same > compiler). Warnings are an art form, and not an exact science, > precisely because the C standard does not (rather, cannot) specify them. If you like to stay in an environment that is based on GCC only, you may use ignore_value(). If you however like to write portable code, you cannot expect something like ignore_value() to be available. Given the fact that other compilers honor the (void) cast, it seems that gcc is trying to be different in a way that just causes pain but that does not give extra value. Jörg -- EMail:joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js@cs.tu-berlin.de (uni) joerg.schilling@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 27 12:11:48 2013 Received: (at 15970) by debbugs.gnu.org; 27 Nov 2013 17:11:48 +0000 Received: from localhost ([127.0.0.1]:47947 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlieS-0007Rv-1i for submit@debbugs.gnu.org; Wed, 27 Nov 2013 12:11:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36377) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VlieO-0007Rl-UO for 15970@debbugs.gnu.org; Wed, 27 Nov 2013 12:11:46 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rARHBh8O029344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Nov 2013 12:11:43 -0500 Received: from [10.3.113.9] ([10.3.113.9]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rARHBgM5031757; Wed, 27 Nov 2013 12:11:42 -0500 Message-ID: <529627CE.3090403@redhat.com> Date: Wed, 27 Nov 2013 10:11:42 -0700 From: Eric Blake Organization: Red Hat, Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Joerg Schilling , P@draigBrady.com Subject: Re: ignore_value vs (void) [was: [Bug-tar] bug#15970: bug#15970: Crash in gettext() after fork() on Mac OS X] References: <20131123033803.GA18735@gaara.hadrons.org> <5290BBFE.7060200@redhat.com> <52929568.6010101@cs.ucla.edu> <52941018.2070909@draigBrady.com> <52947dbe.nr6dEHpaYH/MvwQL%Joerg.Schilling@fokus.fraunhofer.de> <5294956F.4000102@draigBrady.com> <52961e39.FZTibVERBNl2jOgT%Joerg.Schilling@fokus.fraunhofer.de> <52962156.6000202@redhat.com> <52962396.9Q85fOMyjHPXe9Wc%Joerg.Schilling@fokus.fraunhofer.de> <52962468.7070909@redhat.com> <52962663.juBVzwF6YslFl6IE%Joerg.Schilling@fokus.fraunhofer.de> In-Reply-To: <52962663.juBVzwF6YslFl6IE%Joerg.Schilling@fokus.fraunhofer.de> X-Enigmail-Version: 1.6 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TGtIIJtPqIiX3Co4r12PHbumqQIOlQmUN" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 15970 Cc: eggert@cs.ucla.edu, 15970@debbugs.gnu.org, bug-tar@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --TGtIIJtPqIiX3Co4r12PHbumqQIOlQmUN Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/27/2013 10:05 AM, Joerg Schilling wrote: > If you like to stay in an environment that is based on GCC only, you ma= y use=20 > ignore_value(). If you however like to write portable code, you cannot = expect=20 > something like ignore_value() to be available. False. Gnulib already takes care of that; it #defines ignore_value(e) to ((void)(e)) on all non-gcc compilers. In other words, ignore_value() is portable to ANY standards-compliant compiler, and ALSO has the benefit of shutting up warnings on as many compilers as gnulib knows how to test. > Given the fact that other=20 > compilers honor the (void) cast, GCC honors (void) casting - but that doesn't shut up the warning. Just because the standards require (void)expression to compile (and gcc compiles it just fine) doesn't mean that the compiler can't warn about it being suspicious. > it seems that gcc is trying to be different in=20 > a way that just causes pain but that does not give extra value. Maybe, but that cat is already out of the bag, and cross-posting to these lists is not the effective forum to do anything about it. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --TGtIIJtPqIiX3Co4r12PHbumqQIOlQmUN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSlifOAAoJEKeha0olJ0Nqo3IH/A+kACmv+f6wOtyyROylUxZZ Mu/O4AFN21N0I43r4lM8/1Ib2lnC2TUjBp+h0dAvLTyF01Q2HyLtDXx+tfhbm8EC qw39lylmHzn/iSXPkHgCElarFUrI77NqwbOSD8J7fcUOPjUt9WgYdBdbJ0tw9XXE X1iABWR3Cl/U9TIIYYy4A3CkbuIzBTCP7/dj9hKny2kedh3SaETtt5Dxk0Kh1lSp JFCJ0fxeXZxWx1k7RBOUO9nIS1TqygvUsIujS7h/0xfiQ0GFZy1eL4Jl7V1M6W3C 6vdcTzj8ho9ck4T0/fW+S3sYTTxaYQ9gWpIp4UMtZBxKAtTsippiTwR1oPZI54k= =lQJW -----END PGP SIGNATURE----- --TGtIIJtPqIiX3Co4r12PHbumqQIOlQmUN-- From unknown Sat Jun 21 05:00:19 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 26 Dec 2013 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator