From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.emacs.devel Subject: Re: Dumper issue, revisited; invalid realloc/free Date: Wed, 4 Feb 2015 14:13:05 -0500 Message-ID: <20150204191305.GY23507@brightrain.aerifal.cx> References: <20150204175709.GX23507@brightrain.aerifal.cx> <83pp9pfqb3.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1423077200 30677 80.91.229.3 (4 Feb 2015 19:13:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Feb 2015 19:13:20 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 04 20:13:19 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YJ5O3-00043n-8G for ged-emacs-devel@m.gmane.org; Wed, 04 Feb 2015 20:13:19 +0100 Original-Received: from localhost ([::1]:38243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5O2-0003C2-9J for ged-emacs-devel@m.gmane.org; Wed, 04 Feb 2015 14:13:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5Nv-0003AN-4r for emacs-devel@gnu.org; Wed, 04 Feb 2015 14:13:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJ5Nq-0004LN-Er for emacs-devel@gnu.org; Wed, 04 Feb 2015 14:13:11 -0500 Original-Received: from 216-12-86-13.cv.mvl.ntelos.net ([216.12.86.13]:51455 helo=brightrain.aerifal.cx) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5Nq-0004LH-A2 for emacs-devel@gnu.org; Wed, 04 Feb 2015 14:13:06 -0500 Original-Received: from dalias by brightrain.aerifal.cx with local (Exim 3.15 #2) id 1YJ5Np-0004B8-00; Wed, 04 Feb 2015 19:13:05 +0000 Content-Disposition: inline In-Reply-To: <83pp9pfqb3.fsf@gnu.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 216.12.86.13 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:182388 Archived-At: On Wed, Feb 04, 2015 at 09:08:00PM +0200, Eli Zaretskii wrote: > > Date: Wed, 4 Feb 2015 12:57:09 -0500 > > From: Rich Felker > > > > The simplest solution I can find is to make the affected free > > functions (xrealloc, xfree, lisp_free, and lisp_align_free) check > > whether their argument is in the range of data_start...initial_brk and > > act as a nop (or in the case of xrealloc, allocate a new object > > without freeing the old one) when this is the case. The check is > > easily accomplished by saving initial_brk=sbrk(0) at startup (to be > > lazy I did this with attribute((constructor)) but other approaches > > might be preferred for an upstream fix. For xrealloc, since the old > > size is not known, I simply estimate it as initial_brk-block. Copying > > up to the min or this value and the new size should be safe, anyway. > > > > Does this sound acceptable for upstream? > > Yes. Several platforms (Cygwin and MinGW on MS-Windows) already do > exactly that. Where is the code that does this? I don't see it in alloc.c. Is it only used when system_malloc=no? The case where it's really needed is for system_malloc=yes... Rich