From unknown Sun Jun 22 08:04:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#10042: VIRT_ADDR_VARIES fix for Emacs under valgrind etc. Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Nov 2011 04:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 10042 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 10042@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.132124655018274 (code B ref -1); Mon, 14 Nov 2011 04:56:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Nov 2011 04:55:50 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RPoaE-0004kh-8j for submit@debbugs.gnu.org; Sun, 13 Nov 2011 23:55:50 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RPoaA-0004kT-9c for submit@debbugs.gnu.org; Sun, 13 Nov 2011 23:55:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPoZY-0002vh-4x for submit@debbugs.gnu.org; Sun, 13 Nov 2011 23:55:09 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:33837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPoZY-0002vJ-0W for submit@debbugs.gnu.org; Sun, 13 Nov 2011 23:55:08 -0500 Received: from eggs.gnu.org ([140.186.70.92]:42084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPoZW-0002Hx-4A for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2011 23:55:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPoZU-0002sL-DO for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2011 23:55:06 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:49588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPoZT-0002rY-VR for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2011 23:55:04 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 777E8A60002 for ; Sun, 13 Nov 2011 20:55:02 -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 sRDZ91NP+APO for ; Sun, 13 Nov 2011 20:55:01 -0800 (PST) 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 4D3E539E800A for ; Sun, 13 Nov 2011 20:55:01 -0800 (PST) Message-ID: <4EC09F27.1080407@cs.ucla.edu> Date: Sun, 13 Nov 2011 20:55:03 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.6 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.6 (----) This is a followup to the thread that began at . This patch fixes a bug where Emacs won't run correctly under valgrind. As Andreas mentioned, without the patch Emacs probably isn't all that safe even when run outside of valgrind. # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: eggert@cs.ucla.edu-20111114043522-l0gmk07ckh964xtp # target_branch: bzr+ssh://eggert@bzr.savannah.gnu.org/emacs/trunk # testament_sha1: 6e35062324740218b862c3bc27e0aed206fee1ee # timestamp: 2011-11-13 20:42:27 -0800 # base_revision_id: rgm@gnu.org-20111114021401-gnrqc3mar3ra6cjp # # Begin patch === modified file 'src/ChangeLog' --- src/ChangeLog 2011-11-12 12:11:54 +0000 +++ src/ChangeLog 2011-11-14 04:35:22 +0000 @@ -1,3 +1,22 @@ +2011-11-14 Paul Eggert + + Standardize on VIRT_ADDR_VARIES behavior; otherwise, valgrind + does not work on some platforms. Problem reported by Andreas Schwab in + . + * puresize.h (pure, PURE_P): Always behave as if VIRT_ADDR_VARIES + is set, removing the need for VIRT_ADDRESS_VARIES. + (PURE_P): Use a more-efficient implementation that needs just one + comparison, not two: on x86-64 with GCC 4.6.2, this cut down the + number of instructions from 6 (xorl, cmpq, jge, xorl, cmpq, setge) + to 4 (xorl, subq, cmpq, setbe). + * alloc.c (pure): Always extern now, since that's the + VIRT_ADDR_VARIES behavior. + (PURE_POINTER_P): Use a single comparison, not two, for + consistency with the new puresize.h. + * lisp.h (PNTR_COMPARISON_TYPE): Remove; no longer needed. + * m/ibms390.h, m/intel386.h, m/template.h, s/cygwin.h, s/hpux10-20.h: + Remove VIRT_ADDR_VARIES no longer needed. + 2011-11-12 Eli Zaretskii * makefile.w32-in (HEAPSIZE): New variable, allows to build temacs === modified file 'src/alloc.c' --- src/alloc.c 2011-11-07 05:37:49 +0000 +++ src/alloc.c 2011-11-10 08:14:27 +0000 @@ -203,9 +203,6 @@ remapping on more recent systems because this is less important nowadays than in the days of small memories and timesharing. */ -#ifndef VIRT_ADDR_VARIES -static -#endif EMACS_INT pure[(PURESIZE + sizeof (EMACS_INT) - 1) / sizeof (EMACS_INT)] = {1,}; #define PUREBEG (char *) pure @@ -222,10 +219,7 @@ /* Value is non-zero if P points into pure space. */ #define PURE_POINTER_P(P) \ - (((PNTR_COMPARISON_TYPE) (P) \ - < (PNTR_COMPARISON_TYPE) ((char *) purebeg + pure_size)) \ - && ((PNTR_COMPARISON_TYPE) (P) \ - >= (PNTR_COMPARISON_TYPE) purebeg)) + ((uintptr_t) (P) - (uintptr_t) purebeg <= pure_size) /* Index in pure at which next pure Lisp object will be allocated.. */ === modified file 'src/lisp.h' --- src/lisp.h 2011-11-07 17:04:01 +0000 +++ src/lisp.h 2011-11-10 08:14:27 +0000 @@ -1877,9 +1877,6 @@ CHECK_NATNUM (tmp); \ XSETCDR ((x), tmp); \ } while (0) - -/* Cast pointers to this type to compare them. */ -#define PNTR_COMPARISON_TYPE uintptr_t /* Define a built-in function for calling from Lisp. `lname' should be the name to give the function in Lisp, === modified file 'src/m/ibms390.h' --- src/m/ibms390.h 2011-02-16 01:35:20 +0000 +++ src/m/ibms390.h 2011-11-10 08:14:27 +0000 @@ -17,11 +17,6 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ - -/* Define VIRT_ADDR_VARIES if the virtual addresses of - pure and impure space as loaded can vary, and even their - relative order cannot be relied on. - - Otherwise Emacs assumes that text space precedes data space, - numerically. */ -#define VIRT_ADDR_VARIES +/* This file is a placeholder -- it does not contain any definitions. + At some point we should probably fix this by removing the file + and removing all uses of it. */ === modified file 'src/m/intel386.h' --- src/m/intel386.h 2011-01-31 23:54:50 +0000 +++ src/m/intel386.h 2011-11-10 08:14:27 +0000 @@ -19,7 +19,6 @@ #ifdef WINDOWSNT -#define VIRT_ADDR_VARIES #define DATA_START get_data_start () #endif @@ -28,4 +27,3 @@ /* we cannot get the maximum address for brk */ #define ULIMIT_BREAK_VALUE (32*1024*1024) #endif - === modified file 'src/m/template.h' --- src/m/template.h 2011-02-16 01:35:20 +0000 +++ src/m/template.h 2011-11-10 08:14:27 +0000 @@ -21,14 +21,6 @@ does not define it automatically. Ones defined so far include m68k and many others */ -/* Define VIRT_ADDR_VARIES if the virtual addresses of - pure and impure space as loaded can vary, and even their - relative order cannot be relied on. - - Otherwise Emacs assumes that text space precedes data space, - numerically. */ -#define VIRT_ADDR_VARIES - /* After adding support for a new machine, modify the large case statement in configure.in to recognize reasonable configuration names, and add a description of the system to === modified file 'src/puresize.h' --- src/puresize.h 2011-06-09 19:08:29 +0000 +++ src/puresize.h 2011-11-10 08:14:27 +0000 @@ -75,21 +75,7 @@ /* Define PURE_P. */ -#ifdef VIRT_ADDR_VARIES -/* For machines where text and data can go anywhere - in virtual memory. */ - extern EMACS_INT pure[]; #define PURE_P(obj) \ - ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE) \ - && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure) - -#else /* not VIRT_ADDR_VARIES */ - -extern char my_edata[]; - -#define PURE_P(obj) \ - ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) my_edata) - -#endif /* VIRT_ADDRESS_VARIES */ + ((uintptr_t) XPNTR (obj) - (uintptr_t) pure <= PURESIZE) === modified file 'src/s/cygwin.h' --- src/s/cygwin.h 2011-03-17 05:15:08 +0000 +++ src/s/cygwin.h 2011-11-10 08:14:27 +0000 @@ -91,9 +91,6 @@ why it needed to be changed. */ #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS -/* Virtual addresses of pure and impure space can vary, as on Windows. */ -#define VIRT_ADDR_VARIES - /* Emacs supplies its own malloc, but glib (part of Gtk+) calls memalign and on Cygwin, that becomes the Cygwin-supplied memalign. As malloc is not the Cygwin malloc, the Cygwin memalign always === modified file 'src/s/hpux10-20.h' --- src/s/hpux10-20.h 2011-11-11 23:17:16 +0000 +++ src/s/hpux10-20.h 2011-11-14 04:35:22 +0000 @@ -100,14 +100,6 @@ header sections which lose when `static' is defined away, as it is on HP-UX. (You get duplicate symbol errors on linking). */ #undef _FILE_OFFSET_BITS - -/* Define VIRT_ADDR_VARIES if the virtual addresses of - pure and impure space as loaded can vary, and even their - relative order cannot be relied on. - - Otherwise Emacs assumes that text space precedes data space, - numerically. */ -#define VIRT_ADDR_VARIES /* The data segment on this machine always starts at address 0x40000000. */ #define DATA_SEG_BITS 0x40000000 From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 14 00:00:41 2011 Received: (at control) by debbugs.gnu.org; 14 Nov 2011 05:00:41 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RPoep-0004sP-2h for submit@debbugs.gnu.org; Mon, 14 Nov 2011 00:00:38 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RPoem-0004s8-9h for control@debbugs.gnu.org; Mon, 14 Nov 2011 00:00:33 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 53DCB39E800C for ; Sun, 13 Nov 2011 20:59: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 VXNrz16DbyMN for ; Sun, 13 Nov 2011 20:59:55 -0800 (PST) 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 1575339E800A for ; Sun, 13 Nov 2011 20:59:55 -0800 (PST) Message-ID: <4EC0A04D.3050801@cs.ucla.edu> Date: Sun, 13 Nov 2011 20:59:57 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: forgot to mark 10042 as having a patch Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.9 (--) tags 10042 + patch From unknown Sun Jun 22 08:04:48 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Paul Eggert Subject: bug#10042: closed (Re: VIRT_ADDR_VARIES fix for Emacs under valgrind etc.) Message-ID: References: <4EC8722F.8050509@cs.ucla.edu> <4EC09F27.1080407@cs.ucla.edu> X-Gnu-PR-Message: they-closed 10042 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 10042@debbugs.gnu.org Date: Sun, 20 Nov 2011 03:23:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1321759381-14831-1" This is a multi-part message in MIME format... ------------=_1321759381-14831-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #10042: VIRT_ADDR_VARIES fix for Emacs under valgrind etc. which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 10042@debbugs.gnu.org. --=20 10042: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D10042 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1321759381-14831-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 10042-done) by debbugs.gnu.org; 20 Nov 2011 03:22:27 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RRxz9-0003qT-HS for submit@debbugs.gnu.org; Sat, 19 Nov 2011 22:22:27 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RRxz6-0003qL-Q9 for 10042-done@debbugs.gnu.org; Sat, 19 Nov 2011 22:22:25 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 161ADA60006 for <10042-done@debbugs.gnu.org>; Sat, 19 Nov 2011 19:21:18 -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 CATOCVAltPO4 for <10042-done@debbugs.gnu.org>; Sat, 19 Nov 2011 19:21:17 -0800 (PST) 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 C6561A60002 for <10042-done@debbugs.gnu.org>; Sat, 19 Nov 2011 19:21:17 -0800 (PST) Message-ID: <4EC8722F.8050509@cs.ucla.edu> Date: Sat, 19 Nov 2011 19:21:19 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: 10042-done@debbugs.gnu.org Subject: Re: VIRT_ADDR_VARIES fix for Emacs under valgrind etc. References: <4EC09F27.1080407@cs.ucla.edu> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 10042-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.9 (--) No further comment and this does fix a bug so I committed the fix into the trunk as bzr 106440. ------------=_1321759381-14831-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 14 Nov 2011 04:55:50 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RPoaE-0004kh-8j for submit@debbugs.gnu.org; Sun, 13 Nov 2011 23:55:50 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RPoaA-0004kT-9c for submit@debbugs.gnu.org; Sun, 13 Nov 2011 23:55:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPoZY-0002vh-4x for submit@debbugs.gnu.org; Sun, 13 Nov 2011 23:55:09 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:33837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPoZY-0002vJ-0W for submit@debbugs.gnu.org; Sun, 13 Nov 2011 23:55:08 -0500 Received: from eggs.gnu.org ([140.186.70.92]:42084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPoZW-0002Hx-4A for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2011 23:55:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RPoZU-0002sL-DO for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2011 23:55:06 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:49588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RPoZT-0002rY-VR for bug-gnu-emacs@gnu.org; Sun, 13 Nov 2011 23:55:04 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 777E8A60002 for ; Sun, 13 Nov 2011 20:55:02 -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 sRDZ91NP+APO for ; Sun, 13 Nov 2011 20:55:01 -0800 (PST) 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 4D3E539E800A for ; Sun, 13 Nov 2011 20:55:01 -0800 (PST) Message-ID: <4EC09F27.1080407@cs.ucla.edu> Date: Sun, 13 Nov 2011 20:55:03 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: VIRT_ADDR_VARIES fix for Emacs under valgrind etc. Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.6 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.6 (----) This is a followup to the thread that began at . This patch fixes a bug where Emacs won't run correctly under valgrind. As Andreas mentioned, without the patch Emacs probably isn't all that safe even when run outside of valgrind. # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: eggert@cs.ucla.edu-20111114043522-l0gmk07ckh964xtp # target_branch: bzr+ssh://eggert@bzr.savannah.gnu.org/emacs/trunk # testament_sha1: 6e35062324740218b862c3bc27e0aed206fee1ee # timestamp: 2011-11-13 20:42:27 -0800 # base_revision_id: rgm@gnu.org-20111114021401-gnrqc3mar3ra6cjp # # Begin patch === modified file 'src/ChangeLog' --- src/ChangeLog 2011-11-12 12:11:54 +0000 +++ src/ChangeLog 2011-11-14 04:35:22 +0000 @@ -1,3 +1,22 @@ +2011-11-14 Paul Eggert + + Standardize on VIRT_ADDR_VARIES behavior; otherwise, valgrind + does not work on some platforms. Problem reported by Andreas Schwab in + . + * puresize.h (pure, PURE_P): Always behave as if VIRT_ADDR_VARIES + is set, removing the need for VIRT_ADDRESS_VARIES. + (PURE_P): Use a more-efficient implementation that needs just one + comparison, not two: on x86-64 with GCC 4.6.2, this cut down the + number of instructions from 6 (xorl, cmpq, jge, xorl, cmpq, setge) + to 4 (xorl, subq, cmpq, setbe). + * alloc.c (pure): Always extern now, since that's the + VIRT_ADDR_VARIES behavior. + (PURE_POINTER_P): Use a single comparison, not two, for + consistency with the new puresize.h. + * lisp.h (PNTR_COMPARISON_TYPE): Remove; no longer needed. + * m/ibms390.h, m/intel386.h, m/template.h, s/cygwin.h, s/hpux10-20.h: + Remove VIRT_ADDR_VARIES no longer needed. + 2011-11-12 Eli Zaretskii * makefile.w32-in (HEAPSIZE): New variable, allows to build temacs === modified file 'src/alloc.c' --- src/alloc.c 2011-11-07 05:37:49 +0000 +++ src/alloc.c 2011-11-10 08:14:27 +0000 @@ -203,9 +203,6 @@ remapping on more recent systems because this is less important nowadays than in the days of small memories and timesharing. */ -#ifndef VIRT_ADDR_VARIES -static -#endif EMACS_INT pure[(PURESIZE + sizeof (EMACS_INT) - 1) / sizeof (EMACS_INT)] = {1,}; #define PUREBEG (char *) pure @@ -222,10 +219,7 @@ /* Value is non-zero if P points into pure space. */ #define PURE_POINTER_P(P) \ - (((PNTR_COMPARISON_TYPE) (P) \ - < (PNTR_COMPARISON_TYPE) ((char *) purebeg + pure_size)) \ - && ((PNTR_COMPARISON_TYPE) (P) \ - >= (PNTR_COMPARISON_TYPE) purebeg)) + ((uintptr_t) (P) - (uintptr_t) purebeg <= pure_size) /* Index in pure at which next pure Lisp object will be allocated.. */ === modified file 'src/lisp.h' --- src/lisp.h 2011-11-07 17:04:01 +0000 +++ src/lisp.h 2011-11-10 08:14:27 +0000 @@ -1877,9 +1877,6 @@ CHECK_NATNUM (tmp); \ XSETCDR ((x), tmp); \ } while (0) - -/* Cast pointers to this type to compare them. */ -#define PNTR_COMPARISON_TYPE uintptr_t /* Define a built-in function for calling from Lisp. `lname' should be the name to give the function in Lisp, === modified file 'src/m/ibms390.h' --- src/m/ibms390.h 2011-02-16 01:35:20 +0000 +++ src/m/ibms390.h 2011-11-10 08:14:27 +0000 @@ -17,11 +17,6 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ - -/* Define VIRT_ADDR_VARIES if the virtual addresses of - pure and impure space as loaded can vary, and even their - relative order cannot be relied on. - - Otherwise Emacs assumes that text space precedes data space, - numerically. */ -#define VIRT_ADDR_VARIES +/* This file is a placeholder -- it does not contain any definitions. + At some point we should probably fix this by removing the file + and removing all uses of it. */ === modified file 'src/m/intel386.h' --- src/m/intel386.h 2011-01-31 23:54:50 +0000 +++ src/m/intel386.h 2011-11-10 08:14:27 +0000 @@ -19,7 +19,6 @@ #ifdef WINDOWSNT -#define VIRT_ADDR_VARIES #define DATA_START get_data_start () #endif @@ -28,4 +27,3 @@ /* we cannot get the maximum address for brk */ #define ULIMIT_BREAK_VALUE (32*1024*1024) #endif - === modified file 'src/m/template.h' --- src/m/template.h 2011-02-16 01:35:20 +0000 +++ src/m/template.h 2011-11-10 08:14:27 +0000 @@ -21,14 +21,6 @@ does not define it automatically. Ones defined so far include m68k and many others */ -/* Define VIRT_ADDR_VARIES if the virtual addresses of - pure and impure space as loaded can vary, and even their - relative order cannot be relied on. - - Otherwise Emacs assumes that text space precedes data space, - numerically. */ -#define VIRT_ADDR_VARIES - /* After adding support for a new machine, modify the large case statement in configure.in to recognize reasonable configuration names, and add a description of the system to === modified file 'src/puresize.h' --- src/puresize.h 2011-06-09 19:08:29 +0000 +++ src/puresize.h 2011-11-10 08:14:27 +0000 @@ -75,21 +75,7 @@ /* Define PURE_P. */ -#ifdef VIRT_ADDR_VARIES -/* For machines where text and data can go anywhere - in virtual memory. */ - extern EMACS_INT pure[]; #define PURE_P(obj) \ - ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE) \ - && (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure) - -#else /* not VIRT_ADDR_VARIES */ - -extern char my_edata[]; - -#define PURE_P(obj) \ - ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) my_edata) - -#endif /* VIRT_ADDRESS_VARIES */ + ((uintptr_t) XPNTR (obj) - (uintptr_t) pure <= PURESIZE) === modified file 'src/s/cygwin.h' --- src/s/cygwin.h 2011-03-17 05:15:08 +0000 +++ src/s/cygwin.h 2011-11-10 08:14:27 +0000 @@ -91,9 +91,6 @@ why it needed to be changed. */ #define GC_MARK_STACK GC_MAKE_GCPROS_NOOPS -/* Virtual addresses of pure and impure space can vary, as on Windows. */ -#define VIRT_ADDR_VARIES - /* Emacs supplies its own malloc, but glib (part of Gtk+) calls memalign and on Cygwin, that becomes the Cygwin-supplied memalign. As malloc is not the Cygwin malloc, the Cygwin memalign always === modified file 'src/s/hpux10-20.h' --- src/s/hpux10-20.h 2011-11-11 23:17:16 +0000 +++ src/s/hpux10-20.h 2011-11-14 04:35:22 +0000 @@ -100,14 +100,6 @@ header sections which lose when `static' is defined away, as it is on HP-UX. (You get duplicate symbol errors on linking). */ #undef _FILE_OFFSET_BITS - -/* Define VIRT_ADDR_VARIES if the virtual addresses of - pure and impure space as loaded can vary, and even their - relative order cannot be relied on. - - Otherwise Emacs assumes that text space precedes data space, - numerically. */ -#define VIRT_ADDR_VARIES /* The data segment on this machine always starts at address 0x40000000. */ #define DATA_SEG_BITS 0x40000000 ------------=_1321759381-14831-1--