Subject: bug#73933: 30.0.91; Crash on scrolling in buffer with image at the end

From: Eli Zaretskii <[email-masked]>
Date: Mon, 21 Oct 2024 20:44:39 +0300

> From: AKIYAMA Kouhei <[email-masked]>
> Date: Tue, 22 Oct 2024 00:14:38 +0900
> 
> 
> If there is an image at the end of the buffer and only part of it is
> visible at the bottom of the window, scrolling with C-v can cause a
> crash. I noticed this when using image-dired or org-mode (when
> displaying inline images).
> 
> After investigating the minimum configuration for the problem to
> occur, I found that it occurs when the scroll-preserve-screen-position
> variable is set to t and winner-mode is used.
> 
> In my environment (Windows 10), the problem can be reproduced 100%
> with the following steps.
> 
> 1. Download
>    https://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-30/emacs-30.0.91.zip
>    and unzip it.
> 
> 2. Open the bin directory and type emacs -Q from the command prompt to
>    start Emacs.
> 
> 3. Paste the following code into the scratch buffer and evaluate it.
> 
> (progn
>   ;; Minimal configuration
>   (setq scroll-preserve-screen-position t)
>   (winner-mode)
> 
>   ;; Reproduce the situation where the problem occurs
>   ;; (There is an image at the end of the buffer, and only half of it
>   ;; is visible.)
>   (switch-to-buffer (generate-new-buffer "*TEST*"))
>   ;;(setq line-spacing 0)
>   (dotimes (_ (- (window-body-height) 4))
>     (insert "\n"))
>   (require 'svg)
>   (let ((svg (svg-create 300 200)))
>     (svg-rectangle svg 0 0 300 200 :fill "red")
>     (svg-insert-image svg))
>   (goto-char (point-min))
> 
>   ;; Crash
>   (scroll-up-command))
> 
> When evaluated, the "Emacs Abort Dialog" will be displayed. The
> following message will be displayed in the command prompt:

Thanks.  This 24-year old thinko should now be fixed on the emacs-30
branch.