* pdumper memory allocation (new FIXME)
@ 2019-01-31 16:07 Paul Eggert
2019-01-31 16:58 ` Eli Zaretskii
0 siblings, 1 reply; 2+ messages in thread
From: Paul Eggert @ 2019-01-31 16:07 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Emacs development discussions
While making minor simplifications to src/pdumper.c I noticed that
pdumper_load has a comment saying it should not call xmalloc, and yet it
calls xstrdup which works by calling xmalloc. I added a FIXME to point
out the inconsistency.
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? I'm asking because if there are still
multiple heaps with pdumper (either on MS-Windows or elsewhere), I
suspect there will be similar problems elsewhere in the code.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: pdumper memory allocation (new FIXME)
2019-01-31 16:07 pdumper memory allocation (new FIXME) Paul Eggert
@ 2019-01-31 16:58 ` Eli Zaretskii
0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2019-01-31 16:58 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel
> From: Paul Eggert <eggert@cs.ucla.edu>
> Cc: Emacs development discussions <emacs-devel@gnu.org>
> 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-31 16:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-31 16:07 pdumper memory allocation (new FIXME) Paul Eggert
2019-01-31 16:58 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).