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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 70311 in the body.
You can then email your comments to 70311 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#70311; Package emacs. (Tue, 09 Apr 2024 15:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Greg Sexton <gregsexton <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 09 Apr 2024 15:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70311; Package emacs. (Sat, 13 Apr 2024 09:22:03 GMT) Full text and rfc822 format available.

Message #8 received at 70311 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Greg Sexton <gregsexton <at> gmail.com>, Po Lu <luangruo <at> yahoo.com>
Cc: 70311 <at> debbugs.gnu.org
Subject: Re: bug#70311: Crash when dnd-indicate-insertion-point is non-nil
Date: Sat, 13 Apr 2024 12:20:48 +0300
> From: Greg Sexton <gregsexton <at> gmail.com>
> 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.

Po Lu, any comments or suggestions?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70311; Package emacs. (Sat, 13 Apr 2024 11:59:01 GMT) Full text and rfc822 format available.

Message #11 received at 70311 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 70311 <at> debbugs.gnu.org, Greg Sexton <gregsexton <at> gmail.com>
Subject: Re: bug#70311: Crash when dnd-indicate-insertion-point is non-nil
Date: Sat, 13 Apr 2024 19:58:25 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Greg Sexton <gregsexton <at> gmail.com>
>> 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.
>
> Po Lu, any comments or suggestions?

As regards suggestions, none at present.  It's not clear to me why
waiting_for_input should continue to exist, but neither am I especially
satisfied with the present arrangements for calling drag-and-drop
callbacks in nsterm.m: some means should be devised of returning to the
event loop during a DND session, rather than calling Lisp and parts of
redisplay from non-reentrant input handlers that the toolkit can call at
will.

Come to think of it, at the time this kludge was written, I never quite
understood why DND events were never received on Mac OS, when the same
was smooth sailing on GNUstep.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70311; Package emacs. (Sat, 13 Apr 2024 12:08:02 GMT) Full text and rfc822 format available.

Message #14 received at 70311 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 70311 <at> debbugs.gnu.org, gregsexton <at> gmail.com
Subject: Re: bug#70311: Crash when dnd-indicate-insertion-point is non-nil
Date: Sat, 13 Apr 2024 15:06:41 +0300
> From: Po Lu <luangruo <at> yahoo.com>
> Cc: Greg Sexton <gregsexton <at> gmail.com>,  70311 <at> debbugs.gnu.org
> Date: Sat, 13 Apr 2024 19:58:25 +0800
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Greg Sexton <gregsexton <at> gmail.com>
> >> 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.
> >
> > Po Lu, any comments or suggestions?
> 
> As regards suggestions, none at present.  It's not clear to me why
> waiting_for_input should continue to exist, but neither am I especially
> satisfied with the present arrangements for calling drag-and-drop
> callbacks in nsterm.m: some means should be devised of returning to the
> event loop during a DND session, rather than calling Lisp and parts of
> redisplay from non-reentrant input handlers that the toolkit can call at
> will.
> 
> Come to think of it, at the time this kludge was written, I never quite
> understood why DND events were never received on Mac OS, when the same
> was smooth sailing on GNUstep.

So you think the suggested bad-aid is the best we can currently do to
prevent crashes in those cases?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70311; Package emacs. (Sat, 13 Apr 2024 12:29:02 GMT) Full text and rfc822 format available.

Message #17 received at 70311 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 70311 <at> debbugs.gnu.org, gregsexton <at> gmail.com
Subject: Re: bug#70311: Crash when dnd-indicate-insertion-point is non-nil
Date: Sat, 13 Apr 2024 20:28:14 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> So you think the suggested bad-aid is the best we can currently do to
> prevent crashes in those cases?

Yes, unfortunately.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70311; Package emacs. (Sat, 13 Apr 2024 16:02:04 GMT) Full text and rfc822 format available.

Message #20 received at 70311 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 70311 <at> debbugs.gnu.org, gregsexton <at> gmail.com
Subject: Re: bug#70311: Crash when dnd-indicate-insertion-point is non-nil
Date: Sat, 13 Apr 2024 19:00:57 +0300
> 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))))))
 
 (defun dnd-handle-one-url (window action url)
   "Handle one dropped url by calling the appropriate handler.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70311; Package emacs. (Sun, 14 Apr 2024 09:25:02 GMT) Full text and rfc822 format available.

Message #23 received at 70311 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 70311 <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 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.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sun, 14 Apr 2024 10:19:12 GMT) Full text and rfc822 format available.

Notification sent to Greg Sexton <gregsexton <at> gmail.com>:
bug acknowledged by developer. (Sun, 14 Apr 2024 10:19:14 GMT) Full text and rfc822 format available.

Message #28 received at 70311-done <at> debbugs.gnu.org (full text, mbox):

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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 12 May 2024 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 days ago.

Previous Next


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