emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: missing GC protection in Fbyte_code


From: Stefan Monnier
Subject: Re: missing GC protection in Fbyte_code
Date: 24 Aug 2004 17:30:52 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>> If it is really necessary to gcpro because you call a function that
>> calls Fsignal, we would need to add lots of gcpros all around.

>     This isn't gcpro in the normal sense.  The macros involved deal with
>     the bytecode stack, not data on the C stack.  It's been several years,
>     though, and I don't remember details.

> Thanks for the correction.  However, none of this data should ever
> be used again in the case where Fsignal is called.

Yes, it seems a lot of the GC-stuff there assumes that Fsignal can return.

I think a patch along the lines of the sample below would be correct now
that it was decided that Fsignal will only ever return in the `quit' case.

Also Since the byte_stack is allocated on the C stack (via alloca), we
shouldn't actually need to scan it if we use conservative stack scanning
anyway: we could "#define BEFORE_POTENTIAL_GC() ((void)0)" and turn
mark_byte_stack into a nop.  Same thing for those other things allocated on
the stack, i.e. specpdl, catchlist, handlerlist, and backtrace.


        Stefan


PS: Note that the first hunk seems to be needed in any case (i.e. a plain
    bug in the current code).

--- bytecode.c  11 sep 2003 18:14:20 -0400      1.79
+++ bytecode.c  24 aoû 2004 17:18:43 -0400      
@@ -387,6 +387,7 @@
        Vquit_flag = Qnil;                              \
         BEFORE_POTENTIAL_GC ();                                \
        Fsignal (Qquit, Qnil);                          \
+        AFTER_POTENTIAL_GC ();                         \
       }                                                        \
   } while (0)
 
@@ -503,16 +504,12 @@
                v2 = SYMBOL_VALUE (v1);
                if (MISCP (v2) || EQ (v2, Qunbound))
                  {
-                   BEFORE_POTENTIAL_GC ();
                    v2 = Fsymbol_value (v1);
-                   AFTER_POTENTIAL_GC ();
                  }
              }
            else
              {
-               BEFORE_POTENTIAL_GC ();
                v2 = Fsymbol_value (v1);
-               AFTER_POTENTIAL_GC ();
              }
            PUSH (v2);
            break;
@@ -539,9 +536,7 @@
              TOP = Qnil;
            else
              {
-               BEFORE_POTENTIAL_GC ();
-               Fcar (wrong_type_argument (Qlistp, v1));
-               AFTER_POTENTIAL_GC ();
+               wrong_type_argument (Qlistp, v1);
              }
            break;
          }
@@ -557,6 +552,7 @@
        case Bmemq:
          {
            Lisp_Object v1;
+           /* Fmemq might run arbitrary code via QUIT.  */
            BEFORE_POTENTIAL_GC ();
            v1 = POP;
            TOP = Fmemq (TOP, v1);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]