From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/64066 Path: news.gmane.org!not-for-mail From: Reiner Steib Newsgroups: gmane.emacs.pretest.bugs,gmane.emacs.gnus.general Subject: Re: gnus crashes on threads deeper than 333 articles Date: Mon, 04 Dec 2006 17:05:16 +0100 Message-ID: References: <87wt58emyz.fsf@stupidchicken.com> Reply-To: Reiner Steib NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1165248362 4173 80.91.229.10 (4 Dec 2006 16:06:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 4 Dec 2006 16:06:02 +0000 (UTC) Cc: emacs-pretest-bug@gnu.org, Chris Moore , ding@gnus.org Original-X-From: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Mon Dec 04 17:05:59 2006 Return-path: Envelope-to: gebp-emacs-pretest-bug@gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1GrGKD-00089J-KC for gebp-emacs-pretest-bug@gmane.org; Mon, 04 Dec 2006 17:05:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GrGKD-0006g0-79 for gebp-emacs-pretest-bug@gmane.org; Mon, 04 Dec 2006 11:05:49 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GrGK1-0006e4-Sj for emacs-pretest-bug@gnu.org; Mon, 04 Dec 2006 11:05:37 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GrGK0-0006c8-7P for emacs-pretest-bug@gnu.org; Mon, 04 Dec 2006 11:05:37 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GrGK0-0006bp-09 for emacs-pretest-bug@gnu.org; Mon, 04 Dec 2006 11:05:36 -0500 Original-Received: from [134.60.1.1] (helo=mail.uni-ulm.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GrGJz-0006ee-Cf for emacs-pretest-bug@gnu.org; Mon, 04 Dec 2006 11:05:35 -0500 Original-Received: from bridgekeeper.physik.uni-ulm.de (bridgekeeper.physik.uni-ulm.de [134.60.10.123]) by mail.uni-ulm.de (8.13.8/8.13.8) with ESMTP id kB4G5GgU010881; Mon, 4 Dec 2006 17:05:16 +0100 (MET) Original-Received: by bridgekeeper.physik.uni-ulm.de (Postfix, from userid 170) id 1CA68123F5; Mon, 4 Dec 2006 17:05:16 +0100 (CET) Original-To: Chong Yidong X-Face: 'bg&jY[8V'W&:=~6w"|>}#4/T; w~36ei4NNMyKRR.a$n=$|sWFPF1y]a\>6kc\*#GN]UDM| Ywv, vbL^XF1nIp\:F=$Ei2o&mEe:%N~, :3]vtQ~s9u$9izmX$IF@VgGl7/, ^dbuM<3|AO2}.%|%?kZ 2Y=@\U!~cll^=8Z9ihKq%wmUe1Ky(#kl3T'>Qk0Ia3mCBsTk?E(,X Mail-Followup-To: Chong Yidong , Chris Moore , emacs-pretest-bug@gnu.org, ding@gnus.org In-Reply-To: <87wt58emyz.fsf@stupidchicken.com> (Chong Yidong's message of "Sun\, 03 Dec 2006 15\:36\:04 -0500") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.91 (gnu/linux) X-DCC-Misty-Metrics: gemini 1170; Body=4 Fuz1=4 Fuz2=4 X-BeenThere: emacs-pretest-bug@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for CVS Emacs." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Errors-To: emacs-pretest-bug-bounces+gebp-emacs-pretest-bug=gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.pretest.bugs:15439 gmane.emacs.gnus.general:64066 Archived-At: On Sun, Dec 03 2006, Chong Yidong wrote: > Chris Moore writes: > >> I just tried opening a mail folder using nnimap in gnus. >> >> One of the threads in the folder is 834 messages long, and each >> message in the thread is a reply to the previous one which results in >> the thread being 834 messages 'deep'. >> >> The definition of gnus-sort-threads in lisp/gnus/gnus-sum.el does >> this: >> (let ((max-lisp-eval-depth 5000)) >> but it doesn't increase max-specpdl-size. Maybe it should? >> >> Or maybe it shouldn't impose fixed limits on the maximum allowable >> thread length at all. A re-implementation using a loop instead of >> recursion should be able to get around this limit. It's walking the >> thread tree, sorting as it goes. > > The attached patch provides a reimplementation of gnus-sort-threads-1 > that uses a loop instead of recursion. It may be a little too > intricate a change to check into Emacs at this point, though. What do > people think? I searched the archives and I only found one more report about this problem, so it seems to be a *very rare* situation. I'm not sure if such a change should be made now (in the stable series). What about providing an option and keep the current recursive as default? See the patch below (`gnus-sort-threads-loop' is your function). Is your implementation faster or slower than the recursion? --8<---------------cut here---------------start------------->8--- --- gnus-sum.el 09 Nov 2006 13:32:35 +0100 7.163 +++ gnus-sum.el 04 Dec 2006 16:55:43 +0100 @@ -4649,20 +4649,48 @@ (1+ (point-at-eol)) (gnus-delete-line))))))) -(defun gnus-sort-threads-1 (threads func) +(defun gnus-sort-threads-recursive (threads func) (sort (mapcar (lambda (thread) (cons (car thread) (and (cdr thread) - (gnus-sort-threads-1 (cdr thread) func)))) + (gnus-sort-threads-recursive (cdr thread) func)))) threads) func)) +(defun gnus-sort-threads-loop (threads func) + (let* ((superthread (cons nil threads)) + (stack (list (cons superthread threads))) + remaining-threads thread) + (while stack + (setq remaining-threads (cdr (car stack))) + (if remaining-threads + (progn (setq thread (car remaining-threads)) + (setcdr (car stack) (cdr remaining-threads)) + (if (cdr thread) + (push (cons thread (cdr thread)) stack))) + (setq thread (caar stack)) + (setcdr thread (sort (cdr thread) func)) + (pop stack))) + (cdr superthread))) + +(defcustom gnus-sort-threads-function 'gnus-sort-threads-recursive + "Function used to sort threads. +There are two pre-defined functions: +`gnus-sort-threads-recursive', and `gnus-sort-threads-loop'. If +you get an error message \"Variable binding depth exceeds +max-specpdl-size\" during threading, set this variable to +`gnus-sort-threads-loop'." + :group 'gnus-thread + :version "22.1" ;; Gnus 5.10.9 + :type '(choice (const :tag "recursion" gnus-sort-threads-recursive) + (const :tag "loop" gnus-sort-threads-loop))) + (defun gnus-sort-threads (threads) "Sort THREADS." (if (not gnus-thread-sort-functions) threads (gnus-message 8 "Sorting threads...") (let ((max-lisp-eval-depth 5000)) - (prog1 (gnus-sort-threads-1 + (prog1 (funcall gnus-sort-threads-function threads (gnus-make-sort-function gnus-thread-sort-functions)) (gnus-message 8 "Sorting threads...done"))))) --8<---------------cut here---------------end--------------->8--- Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/