emacs-devel
[Top][All Lists]
Advanced

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

Re: Concurrency has landed


From: Paul Eggert
Subject: Re: Concurrency has landed
Date: Thu, 22 Dec 2016 11:23:34 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

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.




reply via email to

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