Subject: Re: bug#17775: 24.4.50; `ispell-command-loop` -- portion of code occasionally returns `nil`.

From: Eli Zaretskii <[email-masked]>
Date: Sat, 14 Jun 2014 11:13:28 +0300

> Date: Fri, 13 Jun 2014 15:43:43 -0700
> From: Keith David Bershatsky <[email-masked]>
> 
> I believe that the following code snippet from `ispell.el` (which I commented out) is responsible for sporadically returning `nil` and causing the function `ispell-command-loop` to fail.  Because the issue is sporadic, I have not yet been able to catch it when running Emacs -Q.  Commenting out the code and replacing it with just `choices` appears to resolve the issue, but I'm not certain what negative affect that might have.
> 
>       (while choices
>          ;; EXPERIMENTAL WITHOUT THESE CONDITIONS ***
>       ;; (and choices
>       ;; (< (if (> (+ 7 (current-column) (length (car choices))
>       ;;        (if (> count ?~) 3 0))
>       ;;     (window-width))
>       ;;  (progn
>       ;;    (insert "\n")
>       ;;    (setq line (1+ line)))
>       ;;      line)
>       ;;    max-lines))

Do you have any evidence that this is the offending code, besides the
(maybe) fact that commenting it out makes the problem go away?  If so,
please show that evidence, because I see nothing in this snippet that
could attempt to treat nil as a number or a marker.

If there's no specific evidence that this snippet is the root cause,
then we need additional information to be able to fix this.  The code
you commented out is important (it handles the case that the number of
possible corrections of a word is more than a single line of the
window could hold), so removing it is not an option.

Here are some ways of providing the additional information:

  . provide a reproducible recipe, starting with "emacs -Q", that can
    be used to reliably reproduce the problem

  . run Emacs under GDB, set a breakpoint at xsignal2, load ispell.el
    (the source, not the .elc byte-compiled file), reproduce the
    error, then type "source /path/to/.gdbinit" at GDB prompt, and
    finally type "xbacktrace" to show the Lisp backtrace which will
    pinpoint the locus of the problem more accurately.

Thanks.

Btw, what was the width of the window when this problem happened?

> Here is a thread I opened a couple of weeks ago on Stackoverflow regarding this issue:
> 
> http://stackoverflow.com/questions/23820002/emacs-debugging-an-ispell-error

Please in the future reproduce the important part of your report here,
instead of pointing to some URL.  (I actually encourage you to report
any such problems directly here, not on Stackoverflow.  It's not like
Emacs lacks dedicated places where to report bugs.)

Here is the important part, for the benefit of others and for the
record:

> A few times each day, I receive an ispell error (like the following) that is corrected by restarting Emacs. Any ideas on how to further troubleshoot this type of error would be greatly appreciated.

> Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
>   ispell-command-loop(("Brae" "Br ea" "Br-ea" "Bra" "Bread" "Break" "Bream"
>     "Brew" "Bret" "Bred" "Area" "Urea") nil "Brea" 2229 2233)
>   ispell-process-line("^Brea, CA ~ 92821\n" nil)
>   ispell-region(1 6771)
>   ispell-buffer()
>   ispell()
>   call-interactively(ispell nil nil)
>   command-execute(ispell)

> The document being spell-checked is in tex-mode (built-in -- i.e., not using AUCTeX). The error (today) comes form a simple address at flush-left:

> 242 S. Orange Avenue\\
> Brea, CA ~ 92821

Thanks.