GNU bug report logs - #70311
Crash when dnd-indicate-insertion-point is non-nil

Previous Next

Package: emacs;

Reported by: Greg Sexton <gregsexton <at> gmail.com>

Date: Tue, 9 Apr 2024 15:00:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#70311: closed (Crash when dnd-indicate-insertion-point is
 non-nil)
Date: Sun, 14 Apr 2024 10:19:12 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 14 Apr 2024 13:17:37 +0300
with message-id <86wmp0meny.fsf <at> gnu.org>
and subject line Re: bug#70311: Crash when dnd-indicate-insertion-point is non-nil
has caused the debbugs.gnu.org bug report #70311,
regarding Crash when dnd-indicate-insertion-point is non-nil
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
70311: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70311
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Greg Sexton <gregsexton <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Crash when dnd-indicate-insertion-point is non-nil
Date: Tue, 9 Apr 2024 11:26:41 +0100
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


[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 70311-done <at> debbugs.gnu.org, gregsexton <at> gmail.com
Subject: Re: bug#70311: Crash when dnd-indicate-insertion-point is non-nil
Date: Sun, 14 Apr 2024 13:17:37 +0300
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: gregsexton <at> gmail.com,  70311 <at> debbugs.gnu.org
> Date: Sun, 14 Apr 2024 17:24:12 +0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Po Lu <luangruo <at> yahoo.com>
> >> Cc: gregsexton <at> gmail.com,  70311 <at> debbugs.gnu.org
> >> Date: Sat, 13 Apr 2024 20:28:14 +0800
> >> 
> >> Eli Zaretskii <eliz <at> gnu.org> writes:
> >> 
> >> > So you think the suggested band-aid is the best we can currently do to
> >> > prevent crashes in those cases?
> >> 
> >> Yes, unfortunately.
> >
> > Does the band-aid below look OK to you?
> >
> > diff --git a/lisp/dnd.el b/lisp/dnd.el
> > index 89652d3..de1c58a 100644
> > --- a/lisp/dnd.el
> > +++ b/lisp/dnd.el
> > @@ -149,8 +149,13 @@ dnd-handle-movement
> >                  (with-selected-window window
> >                    (scroll-down 1))))))))
> >        (when dnd-indicate-insertion-point
> > -        (ignore-errors
> > -          (goto-char (posn-point posn)))))))
> > +        (let ((pos (posn-point posn)))
> > +          ;; We avoid errors here, since on some systems this runs
> > +          ;; when waiting_for_input is non-zero, and that aborts on
> > +          ;; error.
> > +          (if (and pos (<= (point-min) pos (point-max)))
> > +              (goto-char pos)
> > +            pos))))))
> 
> Yes, please install.  Thanks.

Thanks, installed on the emacs-29 branch, and closing the bug.


This bug report was last modified 1 year and 94 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.