Subject: Crash when dnd-indicate-insertion-point is non-nil
From: Greg Sexton <[email-masked]>
To: [email-masked]
Date: Tue, 9 Apr 2024 11:26:41 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Emacs (29.1.90) can crash on Mac OS X when dnd-indicate-insertion-point
is non-nil.

I'm not able to deterministically reproduce this, but I have a high
success rate dragging a file over the window and just randomly moving
it around without releasing the click.

This said, I attached a debugger and found the root cause.

There is code that looks like this in dnd-handle-movement:

  (when dnd-indicate-insertion-point
     (ignore-errors
       (goto-char (posn-point posn))))

posn-point can return nil, which causes goto-char to call
wrong_type_argument, this reaches signal_or_quit (eval.c), which calls
emacs_abort as waiting_for_input is true.

A quick fix might be to when-let the result of posn-point, but I'm
unsure if waiting_for_input being true points to a deeper issue.

--

Greg