Subject: 23.1.91; CRITICAL BUG: process-send-region hangs ntEmacs if region >64K

From: "Jeffrey J. Kosowsky" <[email-masked]>
Date: Mon, 11 Jan 2010 15:16:02 -0500

When using process-send-region-process to send a region more than
 about 64K in size to the command 'cat', emacs hangs forever and is
 *only* recoverable by going out of emacs to kill the 'cat' process. 

The following simple code snippet reproduces the problem where NNNN is
 bigger than about 64K. Just run it on a region containing sufficient
 text...

 (progn (setq process (start-process "test" "tempbuff" "cat"))
 (process-send-region process (point-min) NNNNN))

Note the problem *does* not occur with synchronous use of 'cat' via
call-process-region nor does it occur if you 'cat' the region onto a
file (e.g. using "> tempfile" as part of the &rest args). Also, this
problem does not occur on Linux.

The exact cutoff for when it fails is always within a few thousand
bytes of 64K but varies by file (and may be related to things like
encoding).

The problem also occurs if NNNN is smaller than 64K but you send
multiple separate regions of size >64K in rapid succession.

This seems to be some type of buffering issue.

Also, the bug is not *theoretical* in that it breaks functionality in
the vm.el (viewmail) program.

I am using: GNU Emacs 23.1.91.1 (i386-mingw-nt5.1.2600)
But had the same bug on GNU Emacs 23.1.50.1 (i386-mingw-nt5.1.2600) of
2009-09-23 on YAMALOK and also on ntEmacs 22. Again Linux works just fine.

This bug may or may not be related to the following code snippet found
in the standard tramp.el package:
      ;; Under Windows XP, accept-process-output doesn't return
      ;; sometimes.  So we add an additional timeout.
      (with-timeout ((or timeout 1))
	(accept-process-output proc timeout timeout-msecs)))

-------------------------------------------------------------------------------
In GNU Emacs 23.1.91.1 (i386-mingw-nt5.1.2600)
 of 2010-01-02 on PRETEST
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: C
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default enable-multibyte-characters: t

Major mode: Debugger

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<help-echo> C-x C-f e m <tab> . <tab> <return> y <escape> 
x g l o b a l - s e <tab> <return> <escape> <escape> 
<return> e v a l - e x p <tab> <return> <escape> <escape> 
<return> C-y C-a C-k <help-echo> <down-mouse-1> <mouse-1> 
C-y <help-echo> <down-mouse-1> <mouse-1> C-y 6 0 0 
0 0 ) ) <return> C-n C-n C-n C-n C-n C-n <escape> <escape> 
<return> C-y C-a C-k <help-echo> <down-mouse-1> <mouse-1> 
C-y C-a C-k <help-echo> <down-mouse-1> <mouse-1> C-y 
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b 
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b 
C-b C-b C-b C-b C-b <backspace> <backspace> C-e C-b 
C-b <backspace> <backspace> <backspace> <backspace> 
<backspace> 7 0 0 0 0 C-a C-k C-y <return> <down-mouse-1> 
<mouse-1> <help-echo> <help-echo> <help-echo> <down-mouse-1> 
<mouse-1> <escape> x <down-mouse-1> <mouse-1> r e p 
o <tab> r <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
File emacs.exe is large (31MB), really open? (y or n) 
nil
Entering debugger...
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message smtpmail sendmail regexp-opt ecomplete
rfc822 mml mml-sec password-cache mm-decode mm-bodies mm-encode mailcap
mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader
gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit
mailheader canlock sha1 hex-util hashcash mail-utils emacsbug help-mode
easymenu view debug tooltip ediff-hook vc-hooks lisp-float-type mwheel
dos-w32 disp-table ls-lisp w32-win w32-vars tool-bar dnd fontset image
fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev loaddefs button minibuffer faces cus-face files
text-properties overlay md5 base64 format env code-pages mule custom
widget hashtable-print-readable backquote make-network-process multi-tty
emacs)