emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pdumper memory allocation (new FIXME)


From: Eli Zaretskii
Subject: Re: pdumper memory allocation (new FIXME)
Date: Thu, 31 Jan 2019 18:58:46 +0200

> From: Paul Eggert <address@hidden>
> Cc: Emacs development discussions <address@hidden>
> Date: Thu, 31 Jan 2019 08:07:01 -0800
> 
> The call to xstrdup was added in 2019-01-26T10:08:address@hidden 
> (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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]