yes, that's right.
i hand edited the patches a bit and perhaps the hunk numbers are a bit wrong and
that's why it complained.
Vin Shelton wrote:
I got the following error when applying the patch to src/buffer.c:
patching file src/buffer.c
Hunk #1 FAILED at 438.
patch: **** malformed patch at line 303: buf = Fcdr (elt);
The patch for buffer.c as enclosed looks straightforward (2 hunks) -
in get-file-buffer you're protecting against gc, and in
get_truename_buffer you just added a comment. If you confirm this, I
will apply the patch. Otherwise, just send a corrected version.
- vin
>>>>> On Fri, 14 Jul 2000 19:12:15 -0700, Ben Wing <ben(a)666.com>
said:
Ben> hello vin,
Ben> sorry for the lateness of this but this is a patch for 21.1 including gc fixes i
Ben> made a few days ago due to a crash report from yoshiki. i have been running
Ben> 21.2 with these changes for days with no problems and i think they should be
Ben> quite safe; all they do is be more conservative with gc checking.
Ben> ben
Ben> Vin Shelton wrote:
>>
>> I have applied this to the 21.1 branch for XEmacs.
>> It will appear in 21.1.11 Real Soon Now.
>>
>> - vin
>>
>> >>>>> On 07 May 2000, Adrian Aichner
<aichner(a)ecf.teradyne.com> said:
>>
>> >>>>> "Ben" == Ben Wing <ben(a)666.com> writes:
Ben> adrian, i think the stderr changes are unrelated. you
Ben> probably shouldn't back them out, just the
Ben> enable_child_signals changes.
>>
APA> OK, here's a revised patch tested against 21.1.10 vanilla.
>>
APA> It retains STDERR handling improvements.
>>
APA> Best regards,
>>
APA> Adrian
>>
APA> cd d:\tmp\21.1\xemacs\
APA> cvs diff src
APA> Compilation started at Sun May 07 17:23:56 2000 +0200 (W. Europe Daylight Time)
APA> ? src/call-process.err
APA> ? src/cvs-update.err
APA> ? src/SATISFIED
APA> ? src/stat-fstat
APA> ? src/stat-fstat-h
APA> ? src/temacs.bsc
APA> ? src/temacs.map
APA> ? src/xemacs.opt
APA> cvs server: Diffing src
APA> Index: src/process-nt.c
APA> ===================================================================
APA> RCS file: /usr/CVSroot/XEmacs/xemacs/src/process-nt.c,v
APA> retrieving revision 1.15
APA> diff -u -r1.15 process-nt.c
APA> --- process-nt.c 1999/12/04 04:13:05 1.15
APA> +++ process-nt.c 2000/05/07 15:31:54
APA> @@ -49,7 +49,6 @@
APA> struct nt_process_data
APA> {
APA> HANDLE h_process;
APA> - int need_enable_child_signals;
APA> };
>>
APA> #define NT_DATA(p) ((struct nt_process_data*)((p)->process_data))
APA> @@ -469,7 +468,7 @@
>>
APA> /* Duplicate the stdout handle for use as stderr */
APA> DuplicateHandle(GetCurrentProcess(), hprocout, GetCurrentProcess(),
&hprocerr,
APA> - 0, TRUE, DUPLICATE_SAME_ACCESS);
APA> + 0, TRUE, DUPLICATE_SAME_ACCESS);
>>
APA> /* Stupid Win32 allows to create a pipe with *both* ends either
APA> inheritable or not. We need process ends inheritable, and local
APA> @@ -598,7 +597,7 @@
APA> {
APA> si.hStdInput = hprocin;
APA> si.hStdOutput = hprocout;
APA> - si.hStdError = hprocerr;
APA> + si.hStdError = hprocerr;
APA> si.dwFlags |= STARTF_USESTDHANDLES;
APA> }
>>
APA> @@ -613,7 +612,7 @@
APA> /* These just have been inherited; we do not need a copy */
APA> CloseHandle (hprocin);
APA> CloseHandle (hprocout);
APA> - CloseHandle (hprocerr);
APA> + CloseHandle (hprocerr);
APA> }
>>
APA> /* Handle process creation failure */
APA> @@ -640,18 +639,12 @@
APA> CloseHandle (pi.hProcess);
APA> }
>>
APA> + if (!windowed)
APA> + enable_child_signals (pi.hProcess);
APA> +
APA> ResumeThread (pi.hThread);
APA> CloseHandle (pi.hThread);
>>
APA> - /* Remember to enable child signals later if this is not a windowed
APA> - app. Can't do it right now because that screws up the MKS Toolkit
APA> - shell. */
APA> - if (!windowed)
APA> - {
APA> - NT_DATA(p)->need_enable_child_signals = 10;
APA> - kick_status_notify ();
APA> - }
APA> -
APA> /* Hack to support Windows 95 negative pids */
APA> return ((int)pi.dwProcessId < 0
APA> ? -(int)pi.dwProcessId : (int)pi.dwProcessId);
APA> @@ -670,18 +663,6 @@
APA> nt_update_status_if_terminated (struct Lisp_Process* p)
APA> {
APA> DWORD exit_code;
APA> -
APA> - if (NT_DATA(p)->need_enable_child_signals > 1)
APA> - {
APA> - NT_DATA(p)->need_enable_child_signals -= 1;
APA> - kick_status_notify ();
APA> - }
APA> - else if (NT_DATA(p)->need_enable_child_signals == 1)
APA> - {
APA> - enable_child_signals(NT_DATA(p)->h_process);
APA> - NT_DATA(p)->need_enable_child_signals = 0;
APA> - }
APA> -
APA> if (GetExitCodeProcess (NT_DATA(p)->h_process, &exit_code)
APA> && exit_code != STILL_ACTIVE)
APA> {
APA> @@ -782,14 +763,6 @@
APA> int current_group, int nomsg)
APA> {
APA> struct Lisp_Process *p = XPROCESS (proc);
APA> -
APA> - /* Enable child signals if necessary. This may lose the first
APA> - but it's better than nothing. */
APA> - if (NT_DATA(p)->need_enable_child_signals > 0)
APA> - {
APA> - enable_child_signals(NT_DATA(p)->h_process);
APA> - NT_DATA(p)->need_enable_child_signals = 0;
APA> - }
>>
APA> /* Signal error if SIGNO cannot be sent */
APA> validate_signal_number (signo);
>>
APA> Compilation exited abnormally with code 1 at Sun May 07 17:24:10
>>
APA> --
APA> Adrian Aichner <adrian(a)xemacs.org>
Ben> --
Ben> Ben
Ben> In order to save my hands, I am cutting back on my mail. I also write
Ben> as succinctly as possible -- please don't be offended. If you send me
Ben> mail, you _will_ get a response, but please be patient, especially for
Ben> XEmacs-related mail. If you need an immediate response and it is not
Ben> apparent in your message, please say so. Thanks for your understanding.
Ben> See also
http://www.666.com/ben/chronic-pain/Index: fileio.c
Ben> ===================================================================
Ben> RCS file: /usr/CVSroot/XEmacs/xemacs/src/fileio.c,v
Ben> retrieving revision 1.51.2.24
Ben> diff -u -r1.51.2.24 fileio.c
Ben> --- fileio.c 2000/06/12 04:18:12 1.51.2.24
Ben> +++ fileio.c 2000/07/15 02:08:14
Ben> @@ -740,7 +740,7 @@
Ben> */
Ben> (name, default_directory))
Ben> {
Ben> - /* This function can GC */
Ben> + /* This function can GC. GC-checked 7-11-00 ben */
Ben> Bufbyte *nm;
Ben> Bufbyte *newdir, *p, *o;
Ben> @@ -757,6 +757,10 @@
Ben> #ifdef CYGWIN
Ben> char *user;
Ben> #endif
Ben> + struct gcpro gcpro1, gcpro2;
Ben> +
Ben> + /* both of these get set below */
Ben> + GCPRO2 (name, default_directory);
Ben> CHECK_STRING (name);
Ben> @@ -764,8 +768,11 @@
Ben> call the corresponding file handler. */
Ben> handler = Ffind_file_name_handler (name, Qexpand_file_name);
Ben> if (!NILP (handler))
Ben> - return call3_check_string (handler, Qexpand_file_name, name,
Ben> - default_directory);
Ben> + {
Ben> + UNGCPRO;
Ben> + return call3_check_string (handler, Qexpand_file_name, name,
Ben> + default_directory);
Ben> + }
Ben> /* Use the buffer's default-directory if DEFAULT_DIRECTORY is omitted.
*/
Ben> if (NILP (default_directory))
Ben> @@ -777,7 +784,10 @@
Ben> {
Ben> handler = Ffind_file_name_handler (default_directory, Qexpand_file_name);
Ben> if (!NILP (handler))
Ben> - return call3 (handler, Qexpand_file_name, name, default_directory);
Ben> + {
Ben> + UNGCPRO;
Ben> + return call3 (handler, Qexpand_file_name, name, default_directory);
Ben> + }
Ben> }
Ben> o = XSTRING_DATA (default_directory);
Ben> @@ -809,13 +819,8 @@
Ben> && ! (IS_DIRECTORY_SEP (o[0]))
Ben> #endif /* not WIN32_NATIVE */
Ben> )
Ben> - {
Ben> - struct gcpro gcpro1;
Ben> - GCPRO1 (name);
Ben> - default_directory = Fexpand_file_name (default_directory, Qnil);
Ben> - UNGCPRO;
Ben> - }
Ben> + default_directory = Fexpand_file_name (default_directory, Qnil);
Ben> #ifdef FILE_SYSTEM_CASE
Ben> name = FILE_SYSTEM_CASE (name);
Ben> @@ -918,11 +923,11 @@
Ben> XSTRING_DATA (name)[0] = DRIVE_LETTER (drive);
Ben> XSTRING_DATA (name)[1] = ':';
Ben> }
Ben> - return name;
Ben> + RETURN_UNGCPRO (name);
Ben> #else /* not WIN32_NATIVE */
Ben> if (nm == XSTRING_DATA (name))
Ben> - return name;
Ben> - return build_string ((char *) nm);
Ben> + RETURN_UNGCPRO (name);
Ben> + RETURN_UNGCPRO (build_string ((char *) nm));
Ben> #endif /* not WIN32_NATIVE */
Ben> }
Ben> }
Ben> @@ -1236,7 +1241,7 @@
Ben> CORRECT_DIR_SEPS (target);
Ben> #endif /* WIN32_NATIVE */
Ben> - return make_string (target, o - target);
Ben> + RETURN_UNGCPRO (make_string (target, o - target));
Ben> }
Ben> DEFUN ("file-truename", Ffile_truename, 1, 2, 0, /*
Ben> @@ -2202,7 +2207,7 @@
Ben> */
Ben> (filename))
Ben> {
Ben> - /* This function can call lisp */
Ben> + /* This function can call lisp; GC checked 7-11-00 ben */
Ben> Lisp_Object abspath;
Ben> Lisp_Object handler;
Ben> struct stat statbuf;
Ben> @@ -2229,7 +2234,7 @@
Ben> (filename))
Ben> {
Ben> - /* This function can GC. GC checked 1997.04.10. */
Ben> + /* This function can GC. GC checked 07-11-2000 ben. */
Ben> Lisp_Object abspath;
Ben> Lisp_Object handler;
Ben> struct gcpro gcpro1;
Ben> @@ -3116,7 +3121,7 @@
Ben> int failure;
Ben> int save_errno = 0;
Ben> struct stat st;
Ben> - Lisp_Object fn;
Ben> + Lisp_Object fn = Qnil;
Ben> int speccount = specpdl_depth ();
Ben> int visiting_other = STRINGP (visit);
Ben> int visiting = (EQ (visit, Qt) || visiting_other);
Ben> @@ -3125,12 +3130,23 @@
Ben> Lisp_Object annotations = Qnil;
Ben> struct buffer *given_buffer;
Ben> Bufpos start1, end1;
Ben> + struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
Ben> + struct gcpro ngcpro1, ngcpro2;
Ben> + Lisp_Object curbuf;
Ben> +
Ben> + XSETBUFFER (curbuf, current_buffer);
Ben> - /* #### dmoore - if Fexpand_file_name or handlers kill the buffer,
Ben> + /* start, end, visit, and append are never modified in this fun
Ben> + so we don't protect them. */
Ben> + GCPRO5 (visit_file, filename, codesys, lockname, annotations);
Ben> + NGCPRO2 (curbuf, fn);
Ben> +
Ben> + /* [[ dmoore - if Fexpand_file_name or handlers kill the buffer,
Ben> we should signal an error rather than blissfully continuing
Ben> along. ARGH, this function is going to lose lose lose. We need
Ben> to protect the current_buffer from being destroyed, but the
Ben> - multiple return points make this a pain in the butt. */
Ben> + multiple return points make this a pain in the butt. ]] we do
Ben> + protect curbuf now. --ben */
Ben> #ifdef FILE_CODING
Ben> codesys = Fget_coding_system (codesys);
Ben> @@ -3144,9 +3160,6 @@
Ben> {
Ben> Lisp_Object handler;
Ben> - struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
Ben> -
Ben> - GCPRO5 (start, filename, visit, visit_file, lockname);
Ben> if (visiting_other)
Ben> visit_file = Fexpand_file_name (visit, Qnil);
Ben> @@ -3154,11 +3167,11 @@
Ben> visit_file = filename;
Ben> filename = Fexpand_file_name (filename, Qnil);
Ben> - UNGCPRO;
Ben> -
Ben> if (NILP (lockname))
Ben> lockname = visit_file;
Ben> + /* We used to UNGCPRO here. BAD! visit_file is used below after
Ben> + more Lisp calling. */
Ben> /* If the file name has special constructs in it,
Ben> call the corresponding file handler. */
Ben> handler = Ffind_file_name_handler (filename, Qwrite_region);
Ben> @@ -3177,21 +3190,15 @@
current_buffer-> filename = visit_file;
Ben> MARK_MODELINE_CHANGED;
Ben> }
Ben> + NUNGCPRO;
Ben> + UNGCPRO;
Ben> return val;
Ben> }
Ben> }
Ben> #ifdef CLASH_DETECTION
Ben> if (!auto_saving)
Ben> - {
Ben> - Lisp_Object curbuf;
Ben> - struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
Ben> -
Ben> - XSETBUFFER (curbuf, current_buffer);
Ben> - GCPRO5 (start, filename, visit_file, lockname, curbuf);
Ben> - lock_file (lockname);
Ben> - UNGCPRO;
Ben> - }
Ben> + lock_file (lockname);
Ben> #endif /* CLASH_DETECTION */
Ben> /* Special kludge to simplify auto-saving. */
Ben> @@ -3237,9 +3244,9 @@
Ben> {
Ben> Lisp_Object desc_locative = Fcons (make_int (desc), Qnil);
Ben> Lisp_Object instream = Qnil, outstream = Qnil;
Ben> - struct gcpro gcpro1, gcpro2;
Ben> + struct gcpro nngcpro1, nngcpro2;
Ben> /* need to gcpro; QUIT could happen out of call to write() */
Ben> - GCPRO2 (instream, outstream);
Ben> + NNGCPRO2 (instream, outstream);
Ben> record_unwind_protect (close_file_unwind, desc_locative);
Ben> @@ -3297,7 +3304,6 @@
Ben> save_errno = errno;
Ben> }
Ben> Lstream_close (XLSTREAM (instream));
Ben> - UNGCPRO;
Ben> #ifdef HAVE_FSYNC
Ben> /* Note fsync appears to change the modtime on BSD4.2 (both vax and sun).
Ben> @@ -3331,6 +3337,8 @@
Ben> as necessary). */
Ben> XCAR (desc_locative) = Qnil;
Ben> unbind_to (speccount, Qnil);
Ben> +
Ben> + NNUNGCPRO;
Ben> }
Ben> stat ((char *) XSTRING_DATA (fn), &st);
Ben> @@ -3360,6 +3368,8 @@
Ben> }
Ben> else if (quietly)
Ben> {
Ben> + NUNGCPRO;
Ben> + UNGCPRO;
Ben> return Qnil;
Ben> }
Ben> @@ -3369,19 +3379,21 @@
Ben> message ("Wrote %s", XSTRING_DATA (visit_file));
Ben> else
Ben> {
Ben> - struct gcpro gcpro1;
Ben> Lisp_Object fsp;
Ben> - GCPRO1 (fn);
Ben> + struct gcpro nngcpro1;
Ben> + NNGCPRO1 (fsp);
Ben> fsp = Ffile_symlink_p (fn);
Ben> if (NILP (fsp))
Ben> message ("Wrote %s", XSTRING_DATA (fn));
Ben> else
Ben> message ("Wrote %s (symlink to %s)",
Ben> XSTRING_DATA (fn), XSTRING_DATA (fsp));
Ben> - UNGCPRO;
Ben> + NNUNGCPRO;
Ben> }
Ben> }
Ben> + NUNGCPRO;
Ben> + UNGCPRO;
Ben> return Qnil;
Ben> }
Ben> @@ -3633,7 +3645,7 @@
Ben> */
Ben> (buf))
Ben> {
Ben> - /* This function can call lisp */
Ben> + /* This function can call lisp; GC checked 7-11-00 ben */
Ben> struct buffer *b;
Ben> struct stat st;
Ben> Lisp_Object handler;
Ben> Index: buffer.c
Ben> ===================================================================
Ben> RCS file: /usr/CVSroot/XEmacs/xemacs/src/buffer.c,v
Ben> retrieving revision 1.36.2.33
Ben> diff -u -r1.36.2.33 buffer.c
Ben> --- buffer.c 2000/07/08 09:14:25 1.36.2.33
Ben> +++ buffer.c 2000/07/15 02:08:15
Ben> @@ -438,7 +438,7 @@
Ben> */
Ben> (filename))
Ben> {
Ben> - /* This function can GC. GC checked 1997.04.06. */
Ben> + /* This function can GC. GC checked and fixed 7-11-2000 ben. */
Ben> REGISTER Lisp_Object buf;
Ben> struct gcpro gcpro1;
Ben> @@ -473,15 +473,17 @@
Ben> dn = Ffile_name_directory (filename);
Ben> fn = Ffile_truename (dn, Qnil);
Ben> if (! NILP (fn)) dn = fn;
Ben> - fn = Fexpand_file_name (Ffile_name_nondirectory (filename),
Ben> - dn);
Ben> + /* Formerly the two calls below were combined, but that is
Ben> + not GC-safe because the first call returns unprotected
Ben> + data and the second call can GC. --ben */
Ben> + fn = Ffile_name_nondirectory (filename);
Ben> + fn = Fexpand_file_name (fn, dn);
Ben> }
Ben> filename = fn;
Ben> NUNGCPRO;
Ben> }
Ben> {
Ben> Lisp_Object elt;
Ben> LIST_LOOP_2 (elt, Vbuffer_alist)
Ben> {
Ben> buf = Fcdr (elt);
Ben> @@ -533,6 +535,7 @@
Ben> Lisp_Object
Ben> get_truename_buffer (REGISTER Lisp_Object filename)
Ben> {
Ben> + /* This function can GC. GC correct 7-11-00 ben */
Ben> /* FSFmacs has its own code here and doesn't call get-file-buffer.
Ben> That's because their equivalent of find-file-compare-truenames
Ben> (find-file-existing-other-name) isn't looked at in get-file-buffer.
--
Ben
In order to save my hands, I am cutting back on my mail. I also write
as succinctly as possible -- please don't be offended. If you send me
mail, you _will_ get a response, but please be patient, especially for
XEmacs-related mail. If you need an immediate response and it is not
apparent in your message, please say so. Thanks for your understanding.
See also