emacs-devel
[Top][All Lists]
Advanced

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

Re: /srv/bzr/emacs/trunk r103781: * src/bytecode.c (Fbyte_code): CAR and


From: Daniel Colascione
Subject: Re: /srv/bzr/emacs/trunk r103781: * src/bytecode.c (Fbyte_code): CAR and CDR can GC.
Date: Wed, 30 Mar 2011 12:41:56 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

On 3/30/2011 11:04 AM, Stefan Monnier wrote:
------------------------------------------------------------
revno: 103781
committer: Stefan Monnier<address@hidden>
branch nick: trunk
timestamp: Wed 2011-03-30 14:04:11 -0400
message:
   * src/bytecode.c (Fbyte_code): CAR and CDR can GC.


Wait, what? How? wrong_type_argument never returns. If we run into a problem, we'll throw up to some higher context and never hit the AFTER_POTENTIAL_GC case. BEFORE_POTENTIAL_GC (if it's not a noop) sets the stack top field to point to the top of the stack, but because we never return from wrong_type_argument, we don't care whether the stack is lost. v1 might be on the stack, so the only thing keeping it alive might be stack.top.

Now, Fsignal *does* run signal-hook-function, which of course might GC. But that's done using call2, which will keep error_symbol and data alive even if we do GC, so a GC in this case shouldn't actually cause any problems. Likewise for the debugging hooks. So GC shouldn't actually cause a problem, IIUC.

What am I missing?

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-03-30 13:35:37 +0000
+++ b/src/ChangeLog     2011-03-30 18:04:11 +0000
@@ -1,3 +1,7 @@
+2011-03-30  Stefan Monnier  <address@hidden>
+
+       * bytecode.c (Fbyte_code): CAR and CDR can GC.
+
 2011-03-30  Zachary Kanfer  <address@hidden>  (tiny change)

        * keyboard.c (Fexecute_extended_command): Do log the "suggest key

=== modified file 'src/bytecode.c'
--- a/src/bytecode.c    2011-03-17 02:18:00 +0000
+++ b/src/bytecode.c    2011-03-30 18:04:11 +0000
@@ -554,7 +554,16 @@
          {
            Lisp_Object v1;
            v1 = TOP;
-           TOP = CAR (v1);
+           if (CONSP (v1))
+             TOP = XCAR (v1);
+           else if (NILP (v1))
+             TOP = Qnil;
+           else
+             {
+               BEFORE_POTENTIAL_GC ();
+               wrong_type_argument (Qlistp, v1);
+               AFTER_POTENTIAL_GC ();
+             }
            break;
          }

@@ -580,7 +589,17 @@
          {
            Lisp_Object v1;
            v1 = TOP;
-           TOP = CDR (v1);
+           if (CONSP (v1))
+             TOP = XCDR (v1);
+           else if (NILP (v1))
+             TOP = Qnil;
+           else
+             {
+               BEFORE_POTENTIAL_GC ();
+               wrong_type_argument (Qlistp, v1);
+               AFTER_POTENTIAL_GC ();
+             }
+           break;
            break;
          }

@@ -911,13 +930,13 @@
            v1 = POP;
            v2 = TOP;
            CHECK_NUMBER (v2);
-           AFTER_POTENTIAL_GC ();
            op = XINT (v2);
            immediate_quit = 1;
            while (--op >= 0 && CONSP (v1))
              v1 = XCDR (v1);
            immediate_quit = 0;
            TOP = CAR (v1);
+           AFTER_POTENTIAL_GC ();
            break;
          }




reply via email to

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