re:well, efs kills lemacs-19.10..

jeff (jsparkes@bnr.ca)
Wed, 29 Jun 1994 09:32:00 -0400


In message "well, efs kills lemacs-19.10..", 
'mly@adoc.xerox.com' writes:

>Fri Jun 24 21:14:00 1994
	Fri, 24 Jun 1994 16:48:03 -0700
>   
>   jeff sparkes writes:
>    > It's hard to report those bugs because I'm a beta tester of both; I'm
>    > not sure how many people are doing that.
>    > 
>    > I'm seeing GC bugs, core dumps in mark_object when I have efs running.
>    > How do I make a useful bug report from that?  Hmm, maybe I can set
>    > gc-cons-threshold real small to be pretty close to where the
>    > corruption occurs.
>   
>   The file-handler-alist code has worried me for some time because
>   some very low level function are now running Lisp code.  I have a
>   nagging, wholly unsubstantiated feeling that some variable isn't
>   being GCPRO'd before one of these functions is called.  It's one
>   place to start looking anyway.
>
>It worried me so much that I found and fixed several dozen such places
>when I reluctantly merged in this RMSmacs randomness.  I wouldn't be
>at all surprised to find that more GC-protection is needed.
>
>This is the sort of thing that somebody who understands it can go a
>long way towards fixing by just reading the code carefully.  We just
>need to find such a person with some spare time.

I've already spent some time looking for this.  As I understand it,
function need to gcpro local variables pointing to allocated/consed
memory if they call a function that may cons. (Please correct me if
I'm wrong.)

I went trolling through the functions that called
Ffind_file_name_handler.  I noticed that Fexpand_file_name is called
inconsistently, sometimes the variable used is gcpro'd, sometimes not.
I made them all consistent (in fileio.c at least) and fixed a couple
of other things as well.

This patch fixes both problems I had with efs-1.9. (Or at least has
for the day I've been running it; before I couldn't go 20 minutes
without a problem.)
1. crashing during garbage collection
2. verify-visited-file-modtime erroneously returning nil, which caused
   emacs to think that the file had changed on disk.

===================================================================
RCS file: buffer.c,v
retrieving revision 1.1
diff -c -r1.1 buffer.c
*** 1.1	1994/06/27 15:44:26
--- buffer.c	1994/06/27 15:46:00
***************
*** 314,322 ****
       Lisp_Object filename;
  {
    register Lisp_Object tail, buf, tem;
    CHECK_STRING (filename, 0);
    filename = Fexpand_file_name (filename, Qnil);
! 
    {
      /* If the file name has special constructs in it,
         call the corresponding file handler.  */
--- 314,325 ----
       Lisp_Object filename;
  {
    register Lisp_Object tail, buf, tem;
+   struct gcpro gcpro1;
+ 
+   GCPRO1 (filename);
    CHECK_STRING (filename, 0);
    filename = Fexpand_file_name (filename, Qnil);
!   UNGCPRO;
    {
      /* If the file name has special constructs in it,
         call the corresponding file handler.  */
===================================================================
RCS file: dired.c,v
retrieving revision 1.1
diff -c -r1.1 dired.c
*** 1.1	1994/06/27 15:45:44
--- dired.c	1994/06/27 15:45:58
***************
*** 644,650 ****
--- 644,652 ----
    Lisp_Object handler;
    struct gcpro gcpro1, gcpro2;
  
+   GCPRO1 (filename);
    filename = Fexpand_file_name (filename, Qnil);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
===================================================================
RCS file: fileio.c,v
retrieving revision 1.1
diff -c -r1.1 fileio.c
*** 1.1	1994/06/27 14:34:46
--- fileio.c	1994/06/28 15:09:13
***************
*** 1711,1719 ****
  {
    char dir [MAXPATHLEN];
    Lisp_Object handler;
! 
    CHECK_STRING (dirname, 0);
    dirname = Fexpand_file_name (dirname, Qnil);
  
    handler = Ffind_file_name_handler (dirname, Qmake_directory);
    if (!NILP (handler))
--- 1711,1722 ----
  {
    char dir [MAXPATHLEN];
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (dirname);
    CHECK_STRING (dirname, 0);
    dirname = Fexpand_file_name (dirname, Qnil);
+   UNGCPRO;
  
    handler = Ffind_file_name_handler (dirname, Qmake_directory);
    if (!NILP (handler))
***************
*** 1745,1753 ****
       Lisp_Object dirname;
  {
    Lisp_Object handler;
! 
    CHECK_STRING (dirname, 0);
    dirname = Fexpand_file_name (dirname, Qnil);
  
    handler = Ffind_file_name_handler (dirname, Qdelete_directory);
    if (!NILP (handler))
--- 1748,1759 ----
       Lisp_Object dirname;
  {
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (dirname);
    CHECK_STRING (dirname, 0);
    dirname = Fexpand_file_name (dirname, Qnil);
+   UNGCPRO;
  
    handler = Ffind_file_name_handler (dirname, Qdelete_directory);
    if (!NILP (handler))
***************
*** 1766,1773 ****
--- 1772,1783 ----
       Lisp_Object filename;
  {
    Lisp_Object handler;
+   struct gcpro gcpro1;
+   
+   GCPRO1 (filename);
    CHECK_STRING (filename, 0);
    filename = Fexpand_file_name (filename, Qnil);
+   UNGCPRO;
  
    handler = Ffind_file_name_handler (filename, Qdelete_file);
    if (!NILP (handler))
***************
*** 2046,2054 ****
  {
    Lisp_Object abspath;
    Lisp_Object handler;
! 
    CHECK_STRING (filename, 0);
    abspath = Fexpand_file_name (filename, Qnil);
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
--- 2056,2067 ----
  {
    Lisp_Object abspath;
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (filename);
    CHECK_STRING (filename, 0);
    abspath = Fexpand_file_name (filename, Qnil);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
***************
*** 2071,2079 ****
  {
    Lisp_Object abspath;
    Lisp_Object handler;
! 
    CHECK_STRING (filename, 0);
    abspath = Fexpand_file_name (filename, Qnil);
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
--- 2084,2095 ----
  {
    Lisp_Object abspath;
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (filename);
    CHECK_STRING (filename, 0);
    abspath = Fexpand_file_name (filename, Qnil);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
***************
*** 2095,2103 ****
  {
    Lisp_Object abspath;
    Lisp_Object handler;
! 
    CHECK_STRING (filename, 0);
    abspath = Fexpand_file_name (filename, Qnil);
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
--- 2111,2122 ----
  {
    Lisp_Object abspath;
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (filename);
    CHECK_STRING (filename, 0);
    abspath = Fexpand_file_name (filename, Qnil);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
***************
*** 2124,2132 ****
    int valsize;
    Lisp_Object val;
    Lisp_Object handler;
! 
    CHECK_STRING (filename, 0);
    filename = Fexpand_file_name (filename, Qnil);
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
--- 2143,2154 ----
    int valsize;
    Lisp_Object val;
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (filename);
    CHECK_STRING (filename, 0);
    filename = Fexpand_file_name (filename, Qnil);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
***************
*** 2191,2199 ****
  {
    Lisp_Object abspath, dir;
    Lisp_Object handler;
! 
    CHECK_STRING (filename, 0);
    abspath = Fexpand_file_name (filename, Qnil);
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
--- 2213,2224 ----
  {
    Lisp_Object abspath, dir;
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (filename);
    CHECK_STRING (filename, 0);
    abspath = Fexpand_file_name (filename, Qnil);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
***************
*** 2232,2239 ****
    register Lisp_Object abspath;
    struct stat st;
    Lisp_Object handler;
! 
    abspath = expand_and_dir_to_file (filename, current_buffer->directory);
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
--- 2257,2267 ----
    register Lisp_Object abspath;
    struct stat st;
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (filename);
    abspath = expand_and_dir_to_file (filename, current_buffer->directory);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
***************
*** 2285,2292 ****
    Lisp_Object abspath;
    struct stat st;
    Lisp_Object handler;
! 
    abspath = expand_and_dir_to_file (filename, current_buffer->directory);
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
--- 2313,2323 ----
    Lisp_Object abspath;
    struct stat st;
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (filename);
    abspath = expand_and_dir_to_file (filename, current_buffer->directory);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
***************
*** 2322,2330 ****
  {
    Lisp_Object abspath;
    Lisp_Object handler;
! 
    abspath = Fexpand_file_name (filename, current_buffer->directory);
    CHECK_FIXNUM (mode, 1);
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
--- 2353,2364 ----
  {
    Lisp_Object abspath;
    Lisp_Object handler;
!   struct gcpro gcpro1;
!   
!   GCPRO1 (filename);
    abspath = Fexpand_file_name (filename, current_buffer->directory);
    CHECK_FIXNUM (mode, 1);
+   UNGCPRO;
  
    /* If the file name has special constructs in it,
       call the corresponding file handler.  */
***************
*** 2865,2870 ****
--- 2899,2905 ----
    {
      Lisp_Object handler;
      struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
+     
      GCPRO4 (start, filename, visit, visit_file);
  
      if (visiting_other)
***************
*** 2874,2880 ****
      filename = Fexpand_file_name (filename, Qnil);
  
      UNGCPRO;
! 
      /* If the file name has special constructs in it,
         call the corresponding file handler.  */
      handler = Ffind_file_name_handler (filename, Qwrite_region);
--- 2909,2915 ----
      filename = Fexpand_file_name (filename, Qnil);
  
      UNGCPRO;
!     
      /* If the file name has special constructs in it,
         call the corresponding file handler.  */
      handler = Ffind_file_name_handler (filename, Qwrite_region);
***************
*** 2892,2900 ****
--- 2927,2937 ----
  	    current_buffer->save_length = make_number (Z - BEG);
  	    current_buffer->filename = visit_file;
  	  }
+         UNGCPRO;
  	return val;
        }
    }
+   
  
  #ifdef CLASH_DETECTION
    if (!auto_saving)
***************
*** 3549,3559 ****
      current_buffer->modtime = cons_to_long (time_list);
    else
      {
!       register Lisp_Object filename;
        struct stat st;
        Lisp_Object handler;
! 
        filename = Fexpand_file_name (current_buffer->filename, Qnil);
  
        /* If the file name has special constructs in it,
  	 call the corresponding file handler.  */
--- 3586,3599 ----
      current_buffer->modtime = cons_to_long (time_list);
    else
      {
!       Lisp_Object filename;
        struct stat st;
        Lisp_Object handler;
!       struct gcpro gcpro1;
!       
!       GCPRO1 (filename);
        filename = Fexpand_file_name (current_buffer->filename, Qnil);
+       UNGCPRO;
  
        /* If the file name has special constructs in it,
  	 call the corresponding file handler.  */