unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: James Cloos <cloos@jhcloos.com>
Cc: bugs@gnus.org, 4358@emacsbugs.donarmstrong.com
Subject: bug#4358: 23.1.50; Arithmetic overflow errors break imap
Date: Wed, 09 Sep 2009 11:06:20 -0400	[thread overview]
Message-ID: <jwvtyzcp3ol.fsf-monnier+emacsbugreports@gnu.org> (raw)
In-Reply-To: <m3k509w2v5.fsf@lugabout.jhcloos.org> (James Cloos's message of "Tue, 08 Sep 2009 17:19:34 -0400")

> which (of course) shows that the imapd is sending the large value.
> Which quite simply does not make sense, as there are certainly not
> that many unseen messages in INBOX.  A quick check via telnet shows
> that the imapd does indeed reply to a STATUS INBOX (UNSEEN) command
> with that string, so I'll have to debug that.

Yes, please investigate, to try and seen if it's likely to be a common
problem, or rather a "local error".

> But it would still be nice if gnus didn't crap out when that occurs.

Yes, clearly.

> What can be done to deal with that w/o raising an exception?

Catch the exception and use another number?  In this case, I'd guess
that most-positive-fixnum would do the trick.  Tho, maybe in the general
case, our error signal could/should carry a bit more info so you'd know
whether to use most-positive-fixnum or most-negative-fixnum.

I'd suggest the patch below, tho if you could provide some more info
about your IMAP server (like name and version number), it'd be good to
add it to the comment.


        Stefan


=== modified file 'lisp/net/imap.el'
--- lisp/net/imap.el	2009-09-09 14:17:42 +0000
+++ lisp/net/imap.el	2009-09-09 15:04:06 +0000
@@ -2699,7 +2699,17 @@
 		      (imap-mailbox-put 'uidvalidity (match-string 0) mailbox)
 		      (goto-char (match-end 0))))
 		((string= token "UNSEEN")
-		 (imap-mailbox-put 'unseen (read (current-buffer)) mailbox))
+		 (imap-mailbox-put 'unseen
+                                   (condition-case err
+                                       (read (current-buffer))
+                                     ;; It seems that some IMAP servers can
+                                     ;; return very large unseen numbers,
+                                     ;; like 4294967287 (see bug#4358).
+                                     (overflow-error
+                                      ;; Don't go down without a fight.
+                                      (message "Insanely large number of unseen messages (%s) !!" (cadr err))
+                                      most-positive-fixnum))
+                                   mailbox))
 		(t
 		 (message "Unknown status data %s in mailbox %s ignored"
 			  token mailbox)






  parent reply	other threads:[~2009-09-09 15:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-06 13:47 bug#4358: 23.1.50; Arithmetic overflow errors break imap James Cloos
2009-09-08 20:31 ` Stefan Monnier
2009-09-08 21:19   ` James Cloos
2009-09-09 14:34     ` James Cloos
2009-09-09 15:06     ` Stefan Monnier [this message]
2009-09-09 17:42       ` James Cloos

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwvtyzcp3ol.fsf-monnier+emacsbugreports@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=4358@emacsbugs.donarmstrong.com \
    --cc=bugs@gnus.org \
    --cc=cloos@jhcloos.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).