From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#8545: issues with recent doprnt-related changes Date: Wed, 04 May 2011 00:28:18 -0700 Organization: UCLA Computer Science Department Message-ID: <4DC10012.8020809@cs.ucla.edu> References: <4DB50AB9.6060100@cs.ucla.edu> <83tydmaeo3.fsf@gnu.org> <4DB65FF1.5010003@cs.ucla.edu> <83aafb8p4a.fsf@gnu.org> <4DB8ABEA.3080503@cs.ucla.edu> <4DB9146D.2040702@cs.ucla.edu> <4DB9E5FF.9020506@cs.ucla.edu> <83d3k571ee.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1304494623 27272 80.91.229.12 (4 May 2011 07:37:03 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 4 May 2011 07:37:03 +0000 (UTC) Cc: 8545@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 04 09:36:59 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QHWdn-0006SN-3u for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 May 2011 09:36:59 +0200 Original-Received: from localhost ([::1]:33490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHWdm-0002Dh-MG for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 May 2011 03:36:58 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:47952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHWdk-0002Da-Np for bug-gnu-emacs@gnu.org; Wed, 04 May 2011 03:36:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QHWdj-0005rt-BR for bug-gnu-emacs@gnu.org; Wed, 04 May 2011 03:36:56 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHWdj-0005rp-8H for bug-gnu-emacs@gnu.org; Wed, 04 May 2011 03:36:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QHWW6-0002pz-JS; Wed, 04 May 2011 03:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 May 2011 07:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8545 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8545-submit@debbugs.gnu.org id=B8545.130449410910841 (code B ref 8545); Wed, 04 May 2011 07:29:02 +0000 Original-Received: (at 8545) by debbugs.gnu.org; 4 May 2011 07:28:29 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QHWVZ-0002oo-2k for submit@debbugs.gnu.org; Wed, 04 May 2011 03:28:29 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QHWVW-0002oW-Sg for 8545@debbugs.gnu.org; Wed, 04 May 2011 03:28:28 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 672B139E8108; Wed, 4 May 2011 00:28:21 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-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 qxxAM5iasiSP; Wed, 4 May 2011 00:28:19 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 3F7B239E80F8; Wed, 4 May 2011 00:28:19 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: <83d3k571ee.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 04 May 2011 03:29:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:46186 Archived-At: On 04/29/11 04:16, Eli Zaretskii wrote: > I guess so, yes. I would like to have other opinions, though, so I > will start a new thread on emacs-devel about that. It seems from that discussion that strings can contain MOST_POSITIVE_FIXNUM bytes. Also, that va_arg bug really needs fixing. So I plan to install the following patch after some more testing. This assumes va_copy exists, which may affect the Windows port, but a one-line macro should suffice if it doesn't have va_copy already. === modified file 'ChangeLog' --- ChangeLog 2011-05-04 06:11:49 +0000 +++ ChangeLog 2011-05-04 07:19:21 +0000 @@ -1,5 +1,9 @@ 2011-05-04 Paul Eggert + Use C99's va_copy to avoid undefined behavior on x86-64 GNU/Linux. + * Makefile.in (GNULIB_MODULES): Add stdarg, for va_copy. + * lib/stdarg.in.h, m4/stdarg.m4: New files, from gnulib. + * Makefile.in (GNULIB_TOOL_FLAG): Add --conditional-dependencies. This new gnulib-tool option saves 'configure' the trouble of checking for strtoull when strtoumax exists. === modified file 'Makefile.in' --- Makefile.in 2011-05-04 06:11:49 +0000 +++ Makefile.in 2011-05-04 07:19:21 +0000 @@ -333,7 +333,7 @@ GNULIB_MODULES = \ careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu \ ignore-value intprops lstat mktime readlink \ - socklen stdio strftime strtoumax symlink sys_stat + socklen stdarg stdio strftime strtoumax symlink sys_stat GNULIB_TOOL_FLAGS = \ --conditional-dependencies --import --no-changelog --no-vc-files \ --makefile-name=gnulib.mk === modified file 'src/ChangeLog' --- src/ChangeLog 2011-05-04 06:13:23 +0000 +++ src/ChangeLog 2011-05-04 07:20:46 +0000 @@ -1,5 +1,16 @@ 2011-05-04 Paul Eggert + * term.c (vfatal): Remove stray call to va_end. + It's not needed and the C Standard doesn't allow it here anyway. + + Use C99's va_copy to avoid undefined behavior on x86-64 GNU/Linux. + * eval.c (verror): doprnt a copy of ap, not the original. (Bug#8545) + + * eval.c (verror): OK to create a string of up to MOST_POSITIVE_FIXNUM + bytes. + + * term.c: Don't include , as does that. + Arithmetic overflows now return float rather than wrapping around. (Bug#8611). * data.c: Include . === modified file 'src/eval.c' --- src/eval.c 2011-04-30 19:00:39 +0000 +++ src/eval.c 2011-05-04 07:19:21 +0000 @@ -1994,7 +1994,7 @@ { char buf[4000]; size_t size = sizeof buf; - size_t size_max = min (MOST_POSITIVE_FIXNUM, SIZE_MAX); + size_t size_max = min (MOST_POSITIVE_FIXNUM + 1, SIZE_MAX); size_t mlen = strlen (m); char *buffer = buf; size_t used; @@ -2002,7 +2002,10 @@ while (1) { - used = doprnt (buffer, size, m, m + mlen, ap); + va_list ap_copy; + va_copy (ap_copy, ap); + used = doprnt (buffer, size, m, m + mlen, ap_copy); + va_end (ap_copy); /* Note: the -1 below is because `doprnt' returns the number of bytes excluding the terminating null byte, and it always terminates with a === modified file 'src/term.c' --- src/term.c 2011-04-24 09:00:03 +0000 +++ src/term.c 2011-05-04 07:20:46 +0000 @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "lisp.h" @@ -3619,7 +3618,6 @@ vfprintf (stderr, str, ap); if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n')) fprintf (stderr, "\n"); - va_end (ap); fflush (stderr); exit (1); }