Subject: Re: bug#62216: Odd file corruption in clojure mode and emacs 30 HEAD

From: Eli Zaretskii <[email-masked]>
Date: Wed, 30 Aug 2023 15:00:59 +0300

> From: Gerd Möllmann <[email-masked]>
> Cc: Jonathon McKitrick <[email-masked]>,  Eli Zaretskii <[email-masked]>,  Paul
>  Eggert <[email-masked]>,  [email-masked]
> Date: Wed, 30 Aug 2023 10:59:08 +0200
> 
> Po Lu <[email-masked]> writes:
> 
> > Jonathon McKitrick <[email-masked]> writes:
> >
> >> What's the best mechanism to log these values in emacs?
> >
> > In this case, printf.
> 
> When I add this assumption:
> 
> modified   src/fileio.c
> @@ -4805,8 +4805,11 @@ DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents,
>  
>  	/* 'try' is reserved in some compilers (Microsoft C).  */
>  	ptrdiff_t trytry = min (gap_size, READ_BUF_SIZE);
> +	ptrdiff_t trytry_old = min (total - inserted, READ_BUF_SIZE);
>  	if (!NILP (end))
>  	  trytry = min (trytry, total - inserted);
> +	if (trytry != trytry_old)
> +	  abort ();
>  
>  	if (!seekable && NILP (end))
>  	  {
> 
> and make bootstrap, temacs aborts.
> 
> Can someone tell if this assumption should hold?

You expect READ_BUF_SIZE to never be greater than gap_size?