gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog libbase/GnashException.h server...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog libbase/GnashException.h server...
Date: Wed, 28 Mar 2007 16:24:40 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/03/28 16:24:39

Modified files:
        .              : ChangeLog 
        libbase        : GnashException.h 
        server         : as_environment.cpp as_environment.h 
        server/vm      : ASHandlers.cpp ActionExec.cpp ActionExec.h 

Log message:
                * libbase/GnashException.h: Add ActionLimitException
                * server/as_environment.{cpp,h}: provide callStackDepth()
                  and cleanCallstack() methods, throw an ActionLimitException
                  when reaching 255 call stack depth.
                * server/vm/ActionExec.{cpp,h}: catch ActionLimitException
                  by aborting execution of current code.
                * server/vm/ASHandlers.cpp (ActionCallFunction): pass the
                  environment when converting function name to string.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2702&r2=1.2703
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/GnashException.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.h?cvsroot=gnash&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.h?cvsroot=gnash&r1=1.13&r2=1.14

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2702
retrieving revision 1.2703
diff -u -b -r1.2702 -r1.2703
--- ChangeLog   28 Mar 2007 16:12:08 -0000      1.2702
+++ ChangeLog   28 Mar 2007 16:24:39 -0000      1.2703
@@ -1,3 +1,14 @@
+2007-03-28 Sandro Santilli <address@hidden>
+
+       * libbase/GnashException.h: Add ActionLimitException
+       * server/as_environment.{cpp,h}: provide callStackDepth()
+         and cleanCallstack() methods, throw an ActionLimitException
+         when reaching 255 call stack depth.
+       * server/vm/ActionExec.{cpp,h}: catch ActionLimitException
+         by aborting execution of current code.
+       * server/vm/ASHandlers.cpp (ActionCallFunction): pass the
+         environment when converting function name to string.
+
 2007-03-28 Tomas Groth Christensen <address@hidden>
 
        * backend/sound_handler_gst.cpp: Don't calculate the numbers of 

Index: libbase/GnashException.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/GnashException.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libbase/GnashException.h    23 Jan 2007 17:17:14 -0000      1.5
+++ libbase/GnashException.h    28 Mar 2007 16:24:39 -0000      1.6
@@ -90,6 +90,30 @@
 
 };
 
+/// An ActionScript limit exception 
+//
+/// When this exception is thrown, current execution should
+/// be aborted, stacks and registers cleaning included.
+///
+class ActionLimitException: public GnashException
+{
+
+public:
+
+       ActionLimitException(const std::string& s)
+               :
+               GnashException(s)
+       {}
+
+       ActionLimitException()
+               :
+               GnashException("ActionScript limit hit")
+       {}
+
+       virtual ~ActionLimitException() throw() {}
+
+};
+
 } // namespace gnash
 
 #endif // def _GNASH_GNASHEXCEPTION__H

Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- server/as_environment.cpp   20 Mar 2007 15:01:20 -0000      1.60
+++ server/as_environment.cpp   28 Mar 2007 16:24:39 -0000      1.61
@@ -16,7 +16,7 @@
 
 //
 
-/* $Id: as_environment.cpp,v 1.60 2007/03/20 15:01:20 strk Exp $ */
+/* $Id: as_environment.cpp,v 1.61 2007/03/28 16:24:39 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1011,6 +1011,21 @@
        m_stack.insert(m_stack.begin()+offset, count, as_value());
 }
 
+void
+as_environment::pushCallFrame(as_function* func)
+{
+       const unsigned maxstacksize = 255;
+
+       if ( _localFrames.size() == maxstacksize )
+       {
+               log_warning("Max stack count reached (%u) - should abort 
execution",
+                               maxstacksize);
+               // throw something
+               throw ActionLimitException("Call stack limit exceeded");
+       }
+       _localFrames.push_back(CallFrame(func));
+}
+
 } // end of gnash namespace
 
 

Index: server/as_environment.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- server/as_environment.h     16 Mar 2007 21:06:44 -0000      1.42
+++ server/as_environment.h     28 Mar 2007 16:24:39 -0000      1.43
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: as_environment.h,v 1.42 2007/03/16 21:06:44 strk Exp $ */
+/* $Id: as_environment.h,v 1.43 2007/03/28 16:24:39 strk Exp $ */
 
 #ifndef GNASH_AS_ENVIRONMENT_H
 #define GNASH_AS_ENVIRONMENT_H
@@ -448,10 +448,7 @@
        /// @param func
        ///     The function being called
        ///
-       void pushCallFrame(as_function* func)
-       {
-               _localFrames.push_back(CallFrame(func));
-       }
+       void pushCallFrame(as_function* func);
 
        /// Remove current call frame from the stack
        //
@@ -463,6 +460,18 @@
                _localFrames.pop_back();
        }
 
+       /// Return the depth of call stack
+       size_t callStackDepth()
+       {
+               return _localFrames.size();
+       }
+
+       /// Clear the call stack
+       void clearCallFrames()
+       {
+               _localFrames.clear();
+       }
+
 private:
 
        typedef std::vector<CallFrame> CallStack;

Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- server/vm/ASHandlers.cpp    22 Mar 2007 08:45:52 -0000      1.74
+++ server/vm/ASHandlers.cpp    28 Mar 2007 16:24:39 -0000      1.75
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: ASHandlers.cpp,v 1.74 2007/03/22 08:45:52 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.75 2007/03/28 16:24:39 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -2078,9 +2078,8 @@
        //cerr << "At ActionCallFunction enter:"<<endl;
        //env.dump_stack();
 
-
        // Let's consider it a as a string and lookup the function.
-       as_value function = thread.getVariable(env.top(0).to_std_string());
+       as_value function = thread.getVariable(env.top(0).to_std_string(&env));
        if ( ! function.is_object() ) 
        {
                log_aserror("ActionCallFunction: %s is not an object", 
env.top(0).to_string());

Index: server/vm/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/vm/ActionExec.cpp    6 Mar 2007 16:05:18 -0000       1.22
+++ server/vm/ActionExec.cpp    28 Mar 2007 16:24:39 -0000      1.23
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: ActionExec.cpp,v 1.22 2007/03/06 16:05:18 strk Exp $ */
+/* $Id: ActionExec.cpp,v 1.23 2007/03/28 16:24:39 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -128,7 +128,7 @@
     }
 #endif
                
-    character* original_target = env.get_target();
+    _original_target = env.get_target();
 
     _initial_stack_size = env.stack_size();
 
@@ -147,6 +147,7 @@
        );
 #endif
 
+       try {
        while (pc<stop_pc) {
            // Cleanup any expired "with" blocks.
            while ( ! with_stack.empty() && pc >= with_stack.back().end_pc() ) {
@@ -223,7 +224,30 @@
 
     }
     
-    env.set_target(original_target);
+    }
+    catch (ActionLimitException& ex)
+    {
+           log_aserror("%s", ex.what());
+    }
+    
+    cleanupAfterRun();
+
+}
+
+/*private*/
+void
+ActionExec::cleanupAfterRun()
+{
+    assert(_original_target);
+    env.set_target(_original_target);
+    _original_target = NULL;
+
+    // check the call stack if not in a function context
+    if ( ! isFunction() && env.callStackDepth() > 0 )
+    {
+       log_warning("Call stack non-empty at end of ExecutableCode run (limits 
hit?)");
+       env.clearCallFrames();
+    }
 
     // check if the stack was smashed
     if ( _initial_stack_size > env.stack_size() ) {

Index: server/vm/ActionExec.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/vm/ActionExec.h      6 Mar 2007 16:05:18 -0000       1.13
+++ server/vm/ActionExec.h      28 Mar 2007 16:24:39 -0000      1.14
@@ -43,6 +43,10 @@
 
 private: 
 
+       /// Run after a complete run, or after an run interrupted by 
+       /// a bail-out exception (ActionLimitException, for example)
+       void cleanupAfterRun();
+
        /// the 'with' stack associated with this execution thread
        std::vector<with_stack_entry> with_stack;
 
@@ -80,6 +84,8 @@
 
        size_t _initial_stack_size;
 
+       character* _original_target;
+
        /// Warn about a stack underrun and fix it 
        //
        /// The fix is padding the stack with undefined




reply via email to

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