From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Dumper issue, revisited; invalid realloc/free Date: Wed, 04 Feb 2015 21:44:17 +0200 Message-ID: <83k2zxfomm.fsf@gnu.org> References: <20150204175709.GX23507@brightrain.aerifal.cx> <83oap9fppc.fsf@gnu.org> <20150204193732.GZ23507@brightrain.aerifal.cx> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1423079090 31676 80.91.229.3 (4 Feb 2015 19:44:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Feb 2015 19:44:50 +0000 (UTC) Cc: emacs-devel@gnu.org To: Rich Felker Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 04 20:44:46 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 1YJ5sQ-0007VF-9x for ged-emacs-devel@m.gmane.org; Wed, 04 Feb 2015 20:44:42 +0100 Original-Received: from localhost ([::1]:38436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5sP-0007Dl-OI for ged-emacs-devel@m.gmane.org; Wed, 04 Feb 2015 14:44:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5sD-0007De-IQ for emacs-devel@gnu.org; Wed, 04 Feb 2015 14:44:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJ5sA-0007bK-Ar for emacs-devel@gnu.org; Wed, 04 Feb 2015 14:44:29 -0500 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:38038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5sA-0007b9-2S for emacs-devel@gnu.org; Wed, 04 Feb 2015 14:44:26 -0500 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0NJ900J00ID7QS00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Wed, 04 Feb 2015 21:44:24 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NJ900J3KIU0OF70@a-mtaout21.012.net.il>; Wed, 04 Feb 2015 21:44:24 +0200 (IST) In-reply-to: <20150204193732.GZ23507@brightrain.aerifal.cx> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.169 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:182393 Archived-At: > Date: Wed, 4 Feb 2015 14:37:32 -0500 > From: Rich Felker > Cc: emacs-devel@gnu.org > > > > http://www.openwall.com/lists/musl/2015/02/03/1 > > > > I suggest that you take a look at src/w32heap.c on Emacs's master > > branch. There' you will see a simple solution of a very similar (if > > not identical) problem we have on MS-Windows. It even includes a > > simple handling of large allocations. > > As I suspected, this code is used only if you use gmalloc.c. It's not > used with system_malloc=yes, which is the case I'm concerned about. No, you are mistaken. The 'master' version of Emacs uses the system malloc on MS-Windows. Perhaps you are looking at the 'emacs-24' branch, where indeed we use gmalloc.c and ralloc.c, with sbrk emulation in w32heap.c. But that's not what I had in mind. > > Or that the libc memory allocation routines can gracefully handle > > these situations. > > I would not consider that "graceful". If they detect that the pointer > passed to realloc or free is invalid, the only reasonable behavior is > to abort. They could do exactly what you planned to do: ignore the 'free' part and only allocate a new block.