GNU bug report logs - #66994
30.0.50; Emacs hangs in Todo mode when moving an item to another todo file

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Stephen Berman <stephen.berman@HIDDEN>; dated Tue, 7 Nov 2023 23:15:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 66994 <at> debbugs.gnu.org:


Received: (at 66994) by debbugs.gnu.org; 8 Nov 2023 12:28:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 08 07:28:30 2023
Received: from localhost ([127.0.0.1]:44151 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r0hfa-0002G5-1o
	for submit <at> debbugs.gnu.org; Wed, 08 Nov 2023 07:28:30 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:44876)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r0hfX-0002Fn-L7
 for 66994 <at> debbugs.gnu.org; Wed, 08 Nov 2023 07:28:28 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r0hep-0005lL-DC; Wed, 08 Nov 2023 07:27:43 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ICHhWKgN5A5rInx29JzmboLmxcbzuemGhJl2pKyHO6Y=; b=Wimb4DF5gNWn
 5iFUi5MmURsGptLIAY6tkwTAkA0F1K3hszeBWPWAyLedlAHzmKD05mFJ6H4N6FR05P2zQiFONkZL1
 UVtp8g8Tcc8Y+hqlOnJwAoIgJYVXvy2DalwnGhHvNaeiWxSbToZcAEQPAgyFEKmZjfJVHPNusRm6b
 gNQxk2Msh/YruqkJH4tJCo2sFulW65R+dmTrEVhHdUsf4LwFOKkqoWOMZtNScQasx58or9I1kgUBD
 bS/oh5Gd0T93BsveqPgqK9dY3+8IGNsJNn5mddPDBfmBsCzw8NvlFtOZccGCcSQiatIx03NpJ4mzL
 X8FXLsl6ULy63PoXy1JuOg==;
Date: Wed, 08 Nov 2023 14:27:33 +0200
Message-Id: <83r0l01lca.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stephen Berman <stephen.berman@HIDDEN>
In-Reply-To: <877cmt17j3.fsf@HIDDEN> (message from Stephen Berman on Wed, 08
 Nov 2023 00:13:36 +0100)
Subject: Re: bug#66994: 30.0.50;
 Emacs hangs in Todo mode when moving an item to another todo file
References: <877cmt17j3.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 66994
Cc: 66994 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Stephen Berman <stephen.berman@HIDDEN>
> Date: Wed, 08 Nov 2023 00:13:36 +0100
> 
> Given that it's an old bug that has apparently never been triggered in
> normal use of todo-mode, I have no problem committing the fix to master.
> But since an infinite loop is always nasty and the fix is
> straightforward and AFAICT safe, I think it's suitable for the release
> branch.  I'll wait for the maintainers' decision.

I'm okay with installing this on the emacs-29 branch, but please
improve the comment to the line you added, so that it explains better
why this condition is needed and how it is related to "C-u m":

> -	   (looking-at (regexp-quote todo-category-beg)))
> +	   (looking-at (regexp-quote todo-category-beg))
> +           ;; With `C-u m' to a file that is then loaded into a buffer.
> +	   (= (point) 1))

Also, should this test point-min instead of literally 1?

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#66994; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 7 Nov 2023 23:14:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 07 18:14:29 2023
Received: from localhost ([127.0.0.1]:43733 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r0VHA-0003E6-Mp
	for submit <at> debbugs.gnu.org; Tue, 07 Nov 2023 18:14:29 -0500
Received: from lists.gnu.org ([2001:470:142::17]:56540)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stephen.berman@HIDDEN>) id 1r0VH8-0003Ds-2k
 for submit <at> debbugs.gnu.org; Tue, 07 Nov 2023 18:14:26 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <stephen.berman@HIDDEN>)
 id 1r0VGQ-0008Tr-8h
 for bug-gnu-emacs@HIDDEN; Tue, 07 Nov 2023 18:13:42 -0500
Received: from mout.gmx.net ([212.227.15.18])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <stephen.berman@HIDDEN>)
 id 1r0VGO-0006gv-6p
 for bug-gnu-emacs@HIDDEN; Tue, 07 Nov 2023 18:13:42 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
 s=s31663417; t=1699398816; x=1700003616; i=stephen.berman@HIDDEN;
 bh=HKVerjUHu0tI+i0TTtDfd5jxIpi3SRzvqGagFnyR+xI=;
 h=X-UI-Sender-Class:From:To:Subject:Date;
 b=d4LjVq7qzZE9zQV92Lry7FzpQodnpA/4godMjMp0haJ5o36GuiYUkSA5KudPNGCB
 b1tU8G3yG5LaO69AF9Id8IxUHWFqoxuMR9wzA4X3QNvXZUSqwlr2iF7m8XF+1lKTI
 Y+G5i+qHNql9u+oHxCVeLoTER3NV9aGa9knINnpN6QA8QITE3w8eiANG3QdTK8vPw
 g49umCJ34cKoIZDyc/IE16H/m0CkifQME+s92Ll1xGWwgIKMXKRPZ+G2lJdJxTZL+
 6T6sqsMsIO47IopzS2Q/RVOirbUwUV7V4Gi2AADJ8HnSWOEOo/adA7Fvfe3hiqEzT
 1eVrGnaZi9uOL4hNpA==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Received: from strobelfs2 ([94.134.196.128]) by mail.gmx.net (mrgmx004
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MAONd-1r6sFH2rIB-00BvQM for
 <bug-gnu-emacs@HIDDEN>; Wed, 08 Nov 2023 00:13:36 +0100
From: Stephen Berman <stephen.berman@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; Emacs hangs in Todo mode when moving an item to another
 todo file
Date: Wed, 08 Nov 2023 00:13:36 +0100
Message-ID: <877cmt17j3.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Provags-ID: V03:K1:izaGMARRGb0xE3RUhjw77IC9OTEVVRdnyEV95DV54An2hVtFWPy
 +SehDHc59yk2vbFA/OV6ClWDnf+O9P352GwWLq3zfZMSbhKuk3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+ye7G6d9LamrCNANqf7n2qsQETp
 SpApaFGIsvGjiZQ9eNSuUkKzU+5/fN7yjaktLXr4mUj5AgSmuAqMG1Rq3j5bFrziAqDPCC2wo
 tozYcZ4PQ+UKHaOnGzvXmzQebKk=
Received-SPF: pass client-ip=212.227.15.18;
 envelope-from=stephen.berman@HIDDEN; helo=mout.gmx.net
X-Spam_score_int: -12
X-Spam_score: -1.3
X-Spam_bar: -
X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_WEB=1.5,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 4.5 (++++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  If you have at least two files created using todo-mode, you
 can move an item from a category in one todo file to a category in another
 todo file by typing `C-u m' with point on the item to be moved. B [...] 
 Content analysis details:   (4.5 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 1.5 RCVD_IN_SORBS_WEB      RBL: SORBS: sender is an abusable web server
 [94.134.196.128 listed in dnsbl.sorbs.net]
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (stephen.berman[at]gmx.net)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 2.0 SPOOFED_FREEMAIL       No description available.
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.5 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  If you have at least two files created using todo-mode, you
    can move an item from a category in one todo file to a category in another
    todo file by typing `C-u m' with point on the item to be moved. B [...] 
 
 Content analysis details:   (1.5 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  1.5 RCVD_IN_SORBS_WEB      RBL: SORBS: sender is an abusable web server
                             [94.134.196.128 listed in dnsbl.sorbs.net]
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (stephen.berman[at]gmx.net)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
  1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

--=-=-=
Content-Type: text/plain

If you have at least two files created using todo-mode, you can move an
item from a category in one todo file to a category in another todo file
by typing `C-u m' with point on the item to be moved.  But if the file
the item is to be moved to is not yet visiting a buffer in todo-mode
when the command is invoked, this results in an infinite loop.  The
patch below prevents this and allows the move to succeed.  For those
interested, an analysis of the bug follows.

The call chain leading to the hang is this: todo-move-item ->
todo-set-item-priority -> todo-marked-item-p -> todo-get-overlay ->
todo-item-start.  The latter function tests conditions under which point
is not on an item; if these tests fail, a loop does a search backwards
in the file to find the item start.  But the tests overlook the case at
hand, where a todo file is loaded into a buffer but todo-mode is not yet
set: then point is at the start of the file, whose first line contains
metadata that is hidden in todo-mode.  Since this case is not tested and
the other tests fail, the backwards search begins, but since point is
already at position 1, it is impossible to find an item start, so the
loop is never exited.

Looking through the commit history, it seems this bug has existed since
I first added the code, which was before my rewrite of todo-mode.el was
merged into Emacs.  Evidently I had never tested precisely this use
case.  (One reason for that may be that it is also possible to move an
item between files by typing just `m', when the goal file's name is in
the list `todo-category-completions-files'; but in this case the file is
set to todo-mode before the movement, so the condition triggering the
hang is not met.  I have often used this functionality, but evidently
not the movement with `C-u m'.)  But I now encountered this bug while
testing changes in todo-mode.el to support changing the format of item
date headers, as announced in bug#66395.

Given that it's an old bug that has apparently never been triggered in
normal use of todo-mode, I have no problem committing the fix to master.
But since an infinite loop is always nasty and the fix is
straightforward and AFAICT safe, I think it's suitable for the release
branch.  I'll wait for the maintainers' decision.


In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.18.0) of 2023-11-06 built on strobelfs2
Repository revision: bf81706988f6b1b9d6e8033c8227f0129e04ef03
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
System Description: Linux From Scratch r12.0-63

Configured using:
 'configure -C --with-xwidgets 'CFLAGS=-Og -g3'
 PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM
XINPUT2 XPM XWIDGETS GTK3 ZLIB


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline
Content-Description: todo-item-start patch

diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 093ea0e22b6..86bf3afbce7 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -5277,7 +5277,9 @@ todo-item-start
            ;; Point is on done items separator.
            (save-excursion (beginning-of-line) (looking-at todo-category-done))
 	   ;; Buffer is widened.
-	   (looking-at (regexp-quote todo-category-beg)))
+	   (looking-at (regexp-quote todo-category-beg))
+           ;; With `C-u m' to a file that is then loaded into a buffer.
+	   (= (point) 1))
     (goto-char (line-beginning-position))
     (while (not (looking-at todo-item-start))
       (forward-line -1))

--=-=-=--




Acknowledgement sent to Stephen Berman <stephen.berman@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#66994; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 8 Nov 2023 12:30:02 UTC

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