hello vin,
sorry for the lateness of this but this is a patch for 21.1 including gc fixes i
made a few days ago due to a crash report from yoshiki. i have been running
21.2 with these changes for days with no problems and i think they should be
quite safe; all they do is be more conservative with gc checking.
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
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
http://www.666.com/ben/chronic-pain/
Index: fileio.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/fileio.c,v
retrieving revision 1.51.2.24
diff -u -r1.51.2.24 fileio.c
--- fileio.c 2000/06/12 04:18:12 1.51.2.24
+++ fileio.c 2000/07/15 02:08:14
@@ -740,7 +740,7 @@
*/
(name, default_directory))
{
- /* This function can GC */
+ /* This function can GC. GC-checked 7-11-00 ben */
Bufbyte *nm;
Bufbyte *newdir, *p, *o;
@@ -757,6 +757,10 @@
#ifdef CYGWIN
char *user;
#endif
+ struct gcpro gcpro1, gcpro2;
+
+ /* both of these get set below */
+ GCPRO2 (name, default_directory);
CHECK_STRING (name);
@@ -764,8 +768,11 @@
call the corresponding file handler. */
handler = Ffind_file_name_handler (name, Qexpand_file_name);
if (!NILP (handler))
- return call3_check_string (handler, Qexpand_file_name, name,
- default_directory);
+ {
+ UNGCPRO;
+ return call3_check_string (handler, Qexpand_file_name, name,
+ default_directory);
+ }
/* Use the buffer's default-directory if DEFAULT_DIRECTORY is omitted. */
if (NILP (default_directory))
@@ -777,7 +784,10 @@
{
handler = Ffind_file_name_handler (default_directory, Qexpand_file_name);
if (!NILP (handler))
- return call3 (handler, Qexpand_file_name, name, default_directory);
+ {
+ UNGCPRO;
+ return call3 (handler, Qexpand_file_name, name, default_directory);
+ }
}
o = XSTRING_DATA (default_directory);
@@ -809,13 +819,8 @@
&& ! (IS_DIRECTORY_SEP (o[0]))
#endif /* not WIN32_NATIVE */
)
- {
- struct gcpro gcpro1;
- GCPRO1 (name);
- default_directory = Fexpand_file_name (default_directory, Qnil);
- UNGCPRO;
- }
+ default_directory = Fexpand_file_name (default_directory, Qnil);
#ifdef FILE_SYSTEM_CASE
name = FILE_SYSTEM_CASE (name);
@@ -918,11 +923,11 @@
XSTRING_DATA (name)[0] = DRIVE_LETTER (drive);
XSTRING_DATA (name)[1] = ':';
}
- return name;
+ RETURN_UNGCPRO (name);
#else /* not WIN32_NATIVE */
if (nm == XSTRING_DATA (name))
- return name;
- return build_string ((char *) nm);
+ RETURN_UNGCPRO (name);
+ RETURN_UNGCPRO (build_string ((char *) nm));
#endif /* not WIN32_NATIVE */
}
}
@@ -1236,7 +1241,7 @@
CORRECT_DIR_SEPS (target);
#endif /* WIN32_NATIVE */
- return make_string (target, o - target);
+ RETURN_UNGCPRO (make_string (target, o - target));
}
DEFUN ("file-truename", Ffile_truename, 1, 2, 0, /*
@@ -2202,7 +2207,7 @@
*/
(filename))
{
- /* This function can call lisp */
+ /* This function can call lisp; GC checked 7-11-00 ben */
Lisp_Object abspath;
Lisp_Object handler;
struct stat statbuf;
@@ -2229,7 +2234,7 @@
(filename))
{
- /* This function can GC. GC checked 1997.04.10. */
+ /* This function can GC. GC checked 07-11-2000 ben. */
Lisp_Object abspath;
Lisp_Object handler;
struct gcpro gcpro1;
@@ -3116,7 +3121,7 @@
int failure;
int save_errno = 0;
struct stat st;
- Lisp_Object fn;
+ Lisp_Object fn = Qnil;
int speccount = specpdl_depth ();
int visiting_other = STRINGP (visit);
int visiting = (EQ (visit, Qt) || visiting_other);
@@ -3125,12 +3130,23 @@
Lisp_Object annotations = Qnil;
struct buffer *given_buffer;
Bufpos start1, end1;
+ struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
+ struct gcpro ngcpro1, ngcpro2;
+ Lisp_Object curbuf;
+
+ XSETBUFFER (curbuf, current_buffer);
- /* #### dmoore - if Fexpand_file_name or handlers kill the buffer,
+ /* start, end, visit, and append are never modified in this fun
+ so we don't protect them. */
+ GCPRO5 (visit_file, filename, codesys, lockname, annotations);
+ NGCPRO2 (curbuf, fn);
+
+ /* [[ dmoore - if Fexpand_file_name or handlers kill the buffer,
we should signal an error rather than blissfully continuing
along. ARGH, this function is going to lose lose lose. We need
to protect the current_buffer from being destroyed, but the
- multiple return points make this a pain in the butt. */
+ multiple return points make this a pain in the butt. ]] we do
+ protect curbuf now. --ben */
#ifdef FILE_CODING
codesys = Fget_coding_system (codesys);
@@ -3144,9 +3160,6 @@
{
Lisp_Object handler;
- struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
-
- GCPRO5 (start, filename, visit, visit_file, lockname);
if (visiting_other)
visit_file = Fexpand_file_name (visit, Qnil);
@@ -3154,11 +3167,11 @@
visit_file = filename;
filename = Fexpand_file_name (filename, Qnil);
- UNGCPRO;
-
if (NILP (lockname))
lockname = visit_file;
+ /* We used to UNGCPRO here. BAD! visit_file is used below after
+ more Lisp calling. */
/* If the file name has special constructs in it,
call the corresponding file handler. */
handler = Ffind_file_name_handler (filename, Qwrite_region);
@@ -3177,21 +3190,15 @@
current_buffer->filename = visit_file;
MARK_MODELINE_CHANGED;
}
+ NUNGCPRO;
+ UNGCPRO;
return val;
}
}
#ifdef CLASH_DETECTION
if (!auto_saving)
- {
- Lisp_Object curbuf;
- struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
-
- XSETBUFFER (curbuf, current_buffer);
- GCPRO5 (start, filename, visit_file, lockname, curbuf);
- lock_file (lockname);
- UNGCPRO;
- }
+ lock_file (lockname);
#endif /* CLASH_DETECTION */
/* Special kludge to simplify auto-saving. */
@@ -3237,9 +3244,9 @@
{
Lisp_Object desc_locative = Fcons (make_int (desc), Qnil);
Lisp_Object instream = Qnil, outstream = Qnil;
- struct gcpro gcpro1, gcpro2;
+ struct gcpro nngcpro1, nngcpro2;
/* need to gcpro; QUIT could happen out of call to write() */
- GCPRO2 (instream, outstream);
+ NNGCPRO2 (instream, outstream);
record_unwind_protect (close_file_unwind, desc_locative);
@@ -3297,7 +3304,6 @@
save_errno = errno;
}
Lstream_close (XLSTREAM (instream));
- UNGCPRO;
#ifdef HAVE_FSYNC
/* Note fsync appears to change the modtime on BSD4.2 (both vax and sun).
@@ -3331,6 +3337,8 @@
as necessary). */
XCAR (desc_locative) = Qnil;
unbind_to (speccount, Qnil);
+
+ NNUNGCPRO;
}
stat ((char *) XSTRING_DATA (fn), &st);
@@ -3360,6 +3368,8 @@
}
else if (quietly)
{
+ NUNGCPRO;
+ UNGCPRO;
return Qnil;
}
@@ -3369,19 +3379,21 @@
message ("Wrote %s", XSTRING_DATA (visit_file));
else
{
- struct gcpro gcpro1;
Lisp_Object fsp;
- GCPRO1 (fn);
+ struct gcpro nngcpro1;
+ NNGCPRO1 (fsp);
fsp = Ffile_symlink_p (fn);
if (NILP (fsp))
message ("Wrote %s", XSTRING_DATA (fn));
else
message ("Wrote %s (symlink to %s)",
XSTRING_DATA (fn), XSTRING_DATA (fsp));
- UNGCPRO;
+ NNUNGCPRO;
}
}
+ NUNGCPRO;
+ UNGCPRO;
return Qnil;
}
@@ -3633,7 +3645,7 @@
*/
(buf))
{
- /* This function can call lisp */
+ /* This function can call lisp; GC checked 7-11-00 ben */
struct buffer *b;
struct stat st;
Lisp_Object handler;
Index: buffer.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/src/buffer.c,v
retrieving revision 1.36.2.33
diff -u -r1.36.2.33 buffer.c
--- buffer.c 2000/07/08 09:14:25 1.36.2.33
+++ buffer.c 2000/07/15 02:08:15
@@ -438,7 +438,7 @@
*/
(filename))
{
- /* This function can GC. GC checked 1997.04.06. */
+ /* This function can GC. GC checked and fixed 7-11-2000 ben. */
REGISTER Lisp_Object buf;
struct gcpro gcpro1;
@@ -473,15 +473,17 @@
dn = Ffile_name_directory (filename);
fn = Ffile_truename (dn, Qnil);
if (! NILP (fn)) dn = fn;
- fn = Fexpand_file_name (Ffile_name_nondirectory (filename),
- dn);
+ /* Formerly the two calls below were combined, but that is
+ not GC-safe because the first call returns unprotected
+ data and the second call can GC. --ben */
+ fn = Ffile_name_nondirectory (filename);
+ fn = Fexpand_file_name (fn, dn);
}
filename = fn;
NUNGCPRO;
}
{
Lisp_Object elt;
LIST_LOOP_2 (elt, Vbuffer_alist)
{
buf = Fcdr (elt);
@@ -533,6 +535,7 @@
Lisp_Object
get_truename_buffer (REGISTER Lisp_Object filename)
{
+ /* This function can GC. GC correct 7-11-00 ben */
/* FSFmacs has its own code here and doesn't call get-file-buffer.
That's because their equivalent of find-file-compare-truenames
(find-file-existing-other-name) isn't looked at in get-file-buffer.