Gnus development mailing list
 help / color / mirror / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
Cc: emacs-pretest-bug@gnu.org, ding@gnus.org
Subject: Re: gnus crashes on threads deeper than 333 articles
Date: Sun, 03 Dec 2006 15:36:04 -0500	[thread overview]
Message-ID: <87wt58emyz.fsf@stupidchicken.com> (raw)
In-Reply-To: <E1Gpndn-0003Wt-Dq@chrislap.local> (Chris Moore's message of "Thu\, 30 Nov 2006 16\:15\:59 +0100")

Chris Moore <christopher.ian.moore@gmail.com> 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?

*** emacs/lisp/gnus/gnus-sum.el.~1.93.~	2006-11-24 14:49:06.000000000 -0500
--- emacs/lisp/gnus/gnus-sum.el	2006-12-03 15:25:31.000000000 -0500
***************
*** 4550,4560 ****
  	    (gnus-delete-line)))))))
  
  (defun gnus-sort-threads-1 (threads func)
!   (sort (mapcar (lambda (thread)
! 		  (cons (car thread)
! 			(and (cdr thread)
! 			     (gnus-sort-threads-1 (cdr thread) func))))
! 		threads) func))
  
  (defun gnus-sort-threads (threads)
    "Sort THREADS."
--- 4550,4569 ----
  	    (gnus-delete-line)))))))
  
  (defun gnus-sort-threads-1 (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)))
  
  (defun gnus-sort-threads (threads)
    "Sort THREADS."

       reply	other threads:[~2006-12-03 20:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1Gpndn-0003Wt-Dq@chrislap.local>
2006-12-03 20:36 ` Chong Yidong [this message]
2006-12-04 14:21   ` Richard Stallman
2006-12-04 16:37     ` Chris Moore
2006-12-04 16:59       ` Chris Moore
2006-12-04 18:35         ` Chris Moore
2006-12-04 18:58           ` Reiner Steib
2006-12-04 19:51             ` Chris Moore
2006-12-04 16:05   ` Reiner Steib
2006-12-04 19:05     ` Chong Yidong
2006-12-05  5:09       ` Richard Stallman
2006-12-05  9:29         ` Reiner Steib
2006-12-06  0:47           ` Richard Stallman
2006-12-05 16:52     ` Chong Yidong
2006-12-05 16:59       ` Chong Yidong
2006-12-05 18:59         ` Chris Moore
2006-12-07 16:29         ` Chong Yidong
2006-12-05 17:02       ` Chris Moore
2006-12-05 17:05         ` Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wt58emyz.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=ding@gnus.org \
    --cc=emacs-pretest-bug@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).