GNU bug report logs - #25104
25.1; cursor-sensor--detect can go beyond buffer bounds

Previous Next

Package: emacs;

Reported by: npostavs <at> users.sourceforge.net

Date: Sun, 4 Dec 2016 06:29:01 UTC

Severity: normal

Tags: fixed, patch

Found in version 25.1

Fixed in version 25.2

Done: npostavs <at> users.sourceforge.net

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 25104 in the body.
You can then email your comments to 25104 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#25104; Package emacs. (Sun, 04 Dec 2016 06:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to npostavs <at> users.sourceforge.net:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 04 Dec 2016 06:29:01 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1; cursor-sensor--detect can go beyond buffer bounds
Date: Sun, 04 Dec 2016 01:28:49 -0500
[Message part 1 (text/plain, inline)]
tags: patch

From emacs -Q, insert the following in *scratch*, and evaluate it
twice.

(with-current-buffer (get-buffer-create "foo")
  (erase-buffer)
  (insert (make-string 200 ?\n))
  (cursor-sensor-mode +1)
  (display-buffer (current-buffer)))

The second time an error is triggered, here is a backtrace:

Debugger entered--Lisp error: (args-out-of-range 0)
  get-char-property(0 cursor-sensor-functions)
  cursor-sensor--detect(#<window 9 on *Backtrace*>)
  run-hook-with-args(cursor-sensor--detect #<window 9 on *Backtrace*>)
  redisplay--pre-redisplay-functions((#<window 9 on *Backtrace*>))
  apply(redisplay--pre-redisplay-functions (#<window 9 on *Backtrace*>))
  #[128 "\300\301\"\210\300\302\"\207" [apply redisplay--pre-redisplay-functions ignore nil] 4 nil nil]((#<window 9 on *Backtrace*>))
  redisplay_internal\ \(C\ function\)()

cursor-sensor-mode is a new feature in Emacs 25, so I propose the
following patch for emacs-25:

[v1-0001-Don-t-assume-window-point-and-point-are-the-same.patch (text/plain, inline)]
From 67817cd0727a1b257952afb93fc9a8238965b3c4 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 4 Dec 2016 01:06:52 -0500
Subject: [PATCH v1] Don't assume window-point and point are the same

The function `cursor-sensor--detect' calls `bobp' to decide whether to
check properties at (1- (window-point)).  However, (window-point) may be
at beginning of buffer, even if (point) is not.  In this case an
`args-out-of-range' error will be signaled.

* lisp/emacs-lisp/cursor-sensor.el (cursor-sensor--detect): Check the
value of (window-point) against (point-min), rather than (bobp) to
decide if (1- (window-point)) is accessible.
---
 lisp/emacs-lisp/cursor-sensor.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/cursor-sensor.el b/lisp/emacs-lisp/cursor-sensor.el
index 2231179..28b6188 100644
--- a/lisp/emacs-lisp/cursor-sensor.el
+++ b/lisp/emacs-lisp/cursor-sensor.el
@@ -114,7 +114,7 @@ cursor-sensor--detect
            ;; non-sticky on both ends, but that means get-pos-property might
            ;; never see it.
            (new (or (get-char-property point 'cursor-sensor-functions)
-                    (unless (bobp)
+                    (unless (<= (point-min) point)
                       (get-char-property (1- point) 'cursor-sensor-functions))))
            (old (window-parameter window 'cursor-sensor--last-state))
            (oldposmark (car old))
-- 
2.9.3


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25104; Package emacs. (Sun, 04 Dec 2016 15:40:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: 25104 <at> debbugs.gnu.org
Subject: Re: bug#25104: 25.1; cursor-sensor--detect can go beyond buffer bounds
Date: Sun, 04 Dec 2016 17:39:44 +0200
> From: npostavs <at> users.sourceforge.net
> Date: Sun, 04 Dec 2016 01:28:49 -0500
> 
> cursor-sensor-mode is a new feature in Emacs 25, so I propose the
> following patch for emacs-25:

Thanks, the patch looks trivially correct for me, and I agree it
should go to the release branch.  Please wait for a couple of days
(this being a weekend) for possible comments or objections, and push
then if none are raised.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25104; Package emacs. (Wed, 07 Dec 2016 03:42:02 GMT) Full text and rfc822 format available.

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

From: npostavs <at> users.sourceforge.net
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25104 <at> debbugs.gnu.org
Subject: Re: bug#25104: 25.1; cursor-sensor--detect can go beyond buffer bounds
Date: Tue, 06 Dec 2016 22:41:59 -0500
tags 25104 fixed
close 25104 25.2
quit

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

>> From: npostavs <at> users.sourceforge.net
>> Date: Sun, 04 Dec 2016 01:28:49 -0500
>> 
>> cursor-sensor-mode is a new feature in Emacs 25, so I propose the
>> following patch for emacs-25:
>
> Thanks, the patch looks trivially correct for me, and I agree it
> should go to the release branch.  Please wait for a couple of days
> (this being a weekend) for possible comments or objections, and push
> then if none are raised.

Pushed as 35ce3fb.




Added tag(s) fixed. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 07 Dec 2016 03:42:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 25.2, send any further explanations to 25104 <at> debbugs.gnu.org and npostavs <at> users.sourceforge.net Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Wed, 07 Dec 2016 03:42:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 04 Jan 2017 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 169 days ago.

Previous Next


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