emacs-devel
[Top][All Lists]
Advanced

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

Re: Concurrency has landed


From: Daniel Colascione
Subject: Re: Concurrency has landed
Date: Thu, 22 Dec 2016 11:32:01 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

On Thu, Dec 22 2016, Paul Eggert wrote:
> On 12/21/2016 08:52 PM, Daniel Colascione wrote:
>>> reasons, but also because the byte stack implementation relies on
>>> using pointers to freed storage, which violates the C
>> How?
>
> If memory serves, the code has several pointers p, q, r, ... into a
> memory region based at b that it wants to move. It then does the
> equivalent of 'b1 = realloc (b, newsize); p += b1-b; q += b1-b; r +=
> b1-b; ...; b = b1;'. The C standard does not allow this: a program is
> not allowed to look at a pointer to freed storage (even if it does not
> dereference the pointer), which means the expression 'b1-b' has
> undefined behavior.
>
> Possibly my memory is wrong and realloc was not involved. Regardless,
> the code in question does not work with -fcheck-pointer-bounds, and
> it's confusing to rely on pointers to freed storage, even if you don't
> dereference them and the code happens to work. Also, the byte stack
> isn't needed so we might as well remove it.

Thanks for the clarification: that's one of the less sensible things
about the C standard.  Pointers really ought to work like integers
whether or not they point to freed storage or utter nonsense.

We're not actually *using* the freed storage; that's what I was
worried about.



reply via email to

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