From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: pdumper memory allocation (new FIXME) Date: Thu, 31 Jan 2019 18:58:46 +0200 Message-ID: <83k1ikzruh.fsf@gnu.org> References: <95d4aa4e-bf2f-d18a-9906-95ab5056f065@cs.ucla.edu> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="159067"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 31 17:59:26 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpFgT-000fHM-L8 for ged-emacs-devel@m.gmane.org; Thu, 31 Jan 2019 17:59:25 +0100 Original-Received: from localhost ([127.0.0.1]:57367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpFgS-0005nu-Ls for ged-emacs-devel@m.gmane.org; Thu, 31 Jan 2019 11:59:24 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpFfw-0005nS-QQ for emacs-devel@gnu.org; Thu, 31 Jan 2019 11:58:53 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpFfw-0001vB-8w; Thu, 31 Jan 2019 11:58:52 -0500 Original-Received: from [176.228.60.248] (port=1448 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gpFfv-0000BX-RG; Thu, 31 Jan 2019 11:58:52 -0500 In-reply-to: <95d4aa4e-bf2f-d18a-9906-95ab5056f065@cs.ucla.edu> (message from Paul Eggert on Thu, 31 Jan 2019 08:07:01 -0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:232864 Archived-At: > From: Paul Eggert > Cc: Emacs development discussions > Date: Thu, 31 Jan 2019 08:07:01 -0800 > > The call to xstrdup was added in 2019-01-26T10:08:56!eliz@gnu.org > (a7974933dd818194de3c9387b95dbd122bcf506c), whose commit message says > "Use xstrdup instead of strdup, as on MS-Windows the latter uses the > wrong heap." I thought that with pdumper we no longer have a hybrid > malloc with two heaps; we simply have the usual C heap. Is that not true > in MS-Windows for some reason? There's only one heap on MS-Windows in the pdumper configuration, but it is not the heap used by malloc from the C runtime, it's our private heap we set up in w32heap.c, to better support Emacs memory allocation. The original code called strdup, which on Windows calls the default malloc (because the C runtime was linked against that default malloc implementation), and then the resulting pointer couldn't be free'd later, because by the time we free it, we will have already switched to the private heap. If this call could cause problems to other platforms (I don't think I understand why, perhaps Daniel could show me the light), I'm okay with making the xstrdup call conditioned by WINDOWSNT. Or we could leak the dump file name and not free it, although that sounds less clean to me.