Subject: Re: bug#11519: "Wrong type argument: characterp" building custom-deps while boostrapping

From: Eli Zaretskii <[email-masked]>
Date: Wed, 23 May 2012 05:59:41 +0300

> From: Stefan Monnier <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked],  [email-masked]
> Date: Tue, 22 May 2012 20:47:54 -0400
> 
> I assume that the problem can show up in many other places than
> re_search, so yes, it's a real problem that we need to fix for real, but
> your workaround will only fix the problem we happened to bump into

Which other places use C pointers to buffer text and call functions
that can allocate memory?  If you know about such places, please point
them out.  I don't think we have them, but that's me.

> adding this fix to the emacs-24 branch may be completely useless if this
> bug never shows up at that place there.

That "if" is profoundly false, as I can now easily craft a use case
where it _will_ show up.

Anyway, are you against committing this to the release branch?  I'd be
very sad if you were, having invested so much time in hunting this
bug, but I guess I'll survive.

> >> I wonder: why do we use REL_ALLOC?
> > AFAIK, we do that only on platforms that don't support mmap for
> > allocating buffer text.
> 
> So, IIUC the only reason to use it is so that we can more often return
> memory to the OS even for the non-mmap case?  Is that because returning
> memory can only be done via sbrk style memory management?

I don't think this is only about _returning_ memory.  It is first and
foremost about not _asking_ for more memory when we can come up with
it by reshuffling buffer text.

> I wonder how effective it is in practice.

I have no idea.  ralloc.c was in place (and used by all platforms)
long before I became involved with Emacs.  Perhaps Richard can tell.