From xemacs-m  Mon Jun  9 23:39:43 1997
Received: from crystal.WonderWorks.COM (crystal.WonderWorks.com [192.203.206.1])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id XAA20366
	for <xemacs-beta@xemacs.org>; Mon, 9 Jun 1997 23:39:41 -0500 (CDT)
Received: by crystal.WonderWorks.COM 
	id QQctha11294; Tue, 10 Jun 1997 00:39:43 -0400 (EDT)
Date: Tue, 10 Jun 1997 00:39:43 -0400 (EDT)
Message-Id: <QQctha11294.199706100439@crystal.WonderWorks.COM>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="z30Sk4FWji"
Content-Transfer-Encoding: 7bit
From: Kyle Jones <kyle_jones@wonderworks.com>
To: xemacs-beta@xemacs.org
Subject: [PATCH] 20.3-b4: fix for process output processing crash
X-Mailer: VM 6.33 under 20.3 XEmacs Lucid (beta4)
X-Face: /cA45WHG7jWq>(O3&Z57Y<"WsX5ddc,4c#w0F*zrV#=M
        0@~@,s;b,aMtR5Sqs"+nU.z^CSFQ9t`z2>W,S,]:[+2^
        Nbf6v4g>!&,7R4Ot4Wg{&tm=WX7P["9%a)_da48-^tGy
        ,qz]Z,Zz\{E.,]'EO+F)@$KtF&V


--z30Sk4FWji
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This patach fixes the crash part of the attached bug report.  The
args out of range part will require another patch.  The process
output processing routines seem oblivious to the existence of
before/after-change-functions.

Tue Jun 10 00:34:40 1997  Kyle Jones  <kyle_jones@wonderworks.com>

	* src/process.c (status_notify):
	  Use record_unwind_protect and save_excursion_restore to
	  handle the point and buffer restoration.  Cleaner.  Doesn't
	  crash the editor if before/after-change-functions change
	  things behind our back.


--- 1.1	1997/06/10 00:52:07
+++ 1.2	1997/06/10 01:39:59
@@ -2600,19 +2600,19 @@
 	     when a process becomes runnable.  */
 	  else if (!EQ (symbol, Qrun) && !NILP (p->buffer))
 	    {
-	      Lisp_Object old_read_only = Qnil;
-	      Lisp_Object old = Fcurrent_buffer ();
-	      Bufpos opoint;
-              struct gcpro ngcpro1, ngcpro2;
+	      int speccount = specpdl_depth ();
 
 	      /* Avoid error if buffer is deleted
 		 (probably that's why the process is dead, too) */
 	      if (!BUFFER_LIVE_P (XBUFFER (p->buffer)))
 		continue;
 
-              NGCPRO2 (old, old_read_only);
+	      record_unwind_protect (save_excursion_restore,
+				     save_excursion_save ());
 	      Fset_buffer (p->buffer);
-	      opoint = BUF_PT (current_buffer);
+	      record_unwind_protect (save_excursion_restore,
+				     save_excursion_save ());
+	      specbind(Qbuffer_read_only, Qnil);
 	      /* Insert new output into buffer
 		 at the current end-of-output marker,
 		 thus preserving logical ordering of input and output.  */
@@ -2620,24 +2620,13 @@
 		BUF_SET_PT (current_buffer, marker_position (p->mark));
 	      else
 		BUF_SET_PT (current_buffer, BUF_ZV (current_buffer));
-	      if (BUF_PT (current_buffer) <= opoint)
-		opoint += (string_char_length (XSTRING (msg))
-                           + string_char_length (XSTRING (p->name))
-                           + 10);
-
-	      old_read_only = current_buffer->read_only;
-	      current_buffer->read_only = Qnil;
 	      buffer_insert_c_string (current_buffer, "\nProcess ");
 	      Finsert (1, &p->name);
 	      buffer_insert_c_string (current_buffer, " ");
 	      Finsert (1, &msg);
-	      current_buffer->read_only = old_read_only;
 	      Fset_marker (p->mark, make_int (BUF_PT (current_buffer)),
 			   p->buffer);
-
-	      BUF_SET_PT (current_buffer, opoint);
-	      Fset_buffer (old);
-              NUNGCPRO;
+	      unbind_to(speccount, Qnil);
 	    }
 	}
     } /* end for */



--z30Sk4FWji
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit

Article: 10226 of gnu.emacs.bug
x-gateway: relay2.UU.NET from bug-gnu-emacs to gnu.emacs.bug; Wed, 23 Apr 1997 22:44:19 EDT
Message-ID: <m0wKETh-0008eMC@g62-92.citenet.net>
Approved: bug-gnu-emacs-request@prep.ai.mit.edu
Path: news.wonderworks.com!uunet!in2.uu.net!relay2.uu.net!wendy-fate.uu.net!bug-gnu-emacs
Lines: 29
From: gsstark@mit.edu (Greg Stark)
Sender: bug-gnu-emacs-request@prep.ai.mit.edu
Newsgroups: gnu.emacs.bug
Subject: accept-process-output mishandles the point, causes signals or crashes
Date: Wed, 23 Apr 1997 22:41:45 -0400

In GNU Emacs 19.34.1 (i386-debian-linux-gnu, X toolkit) of Sun Mar 16 1997 on depreciation
configured using `configure  --prefix=/usr --with-pop=yes --with-x=yes --with-x-toolkit=lucid i386-debian-linux'

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

Evaluating the following code causes my emacs to crash with an IOT trap. This
is annoying because it makes it hard to track down the other bug i was trying
to report, namely that accept-process-output signals "Args out of range: 1, 5"
which is wrong, it seems to be keeping a hold of some value of the point that 
is invalid because it doesn't expect the after-change-hook to run.

Here's what someone else, who understands this better than i, said when i
described this to him. I think he was looking at the source at the time:
> Looks like read_process_output is preserving the value of `point' across
> the call to insert_before_markers, which will call the after-change function.

(progn
  (defun foo (beg end len)		
    (delete-region beg end))
  (set-buffer (get-buffer-create "foo"))
  (kill-local-variable 'after-change-function)
  (erase-buffer)
  (insert "foo")
  (goto-char (point-max)) 
  (set (make-local-variable 'after-change-function)
       'foo)
  (setq foo (start-process "foo" (current-buffer) "echo"))
  (accept-process-output))


--z30Sk4FWji
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit



--z30Sk4FWji--

