Subject: bug#77325: Crash in Fjson_parse_buffer: ZV changes underneath it?

From: Eli Zaretskii <[email-masked]>
Date: Fri, 28 Mar 2025 19:21:57 +0300

> From: Daniel Colascione <[email-masked]>
> Cc: [email-masked], Pip Cet <[email-masked]>
> Date: Fri, 28 Mar 2025 10:11:58 -0400
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> Didn't have a good repro.  Pip's fix works though.  I was barking up
> the wrong tree: I'm parsing JSON out of a process buffer in a loop and
> dispatching commands as they come in. One of these commands switched the
> buffer, so in the next iteration of the loop, I started parsing JSON out
> of some other random buffer.  It just so happened that other buffer was
> narrowed, so we crashed.  I'll let Pip do the honors of checking in the
> fix if he wants.

I think we should simply replace each BEG with BEGV and each Z with
ZV.  Emacs should never look outside of the current restriction.

> IGC does GC all the time --- but it's not observable because we pump
> messages from the GC only at dedicated points and run GC hooks only in
> response to these messages. however, notice that on the IGC branch that
> we pump GC messages, including finalizer callbacks, on the allocation
> path for, e.g. various pseudovectors.

You mean, we'll run Lisp as part of displaying messages?  Or what do
you mean by "pump GC messages"?