Subject: Re: bug#76091: 31.0.50; festure/igc: buffer.h:829: Emacs fatal error: assertion failed: BUFFERP (a)

From: Pip Cet <[email-masked]>
Date: Fri, 07 Feb 2025 20:35:10 +0000

"Helmut Eller" <[email-masked]> writes:

> On Fri, Feb 07 2025, Pip Cet wrote:
>
>> It still needs more testing, thought, and comments.  All the volatile
>> stuff is needed because we can't copy a union with word atomicity: all
>> we have is memcpy, which might copy bytewise and result in an invalid
>> intermediate state.
>
> But volatile doesn't guarantee atomicity.  Does it?

No, it doesn't.  But having a volatile structure on the stack guarantees
that none of the pointers in the heap structure can be moved (the
volatile stack structure pins them).

But I see now we do use union assignments in an attempt to get word
atomicity, so maybe the volatile stack structure pinning the pointers
isn't always needed.

Maybe it'd be better to define memcpy_by_words which never reveals
intermediate states.

However, this race condition window should be quite small, so probably
worth thinking about more...

Pip