[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog gui/gui.cpp server/movie_root.c...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog gui/gui.cpp server/movie_root.c... |
Date: |
Tue, 02 Oct 2007 15:44:52 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/10/02 15:44:52
Modified files:
. : ChangeLog
gui : gui.cpp
server : movie_root.cpp movie_root.h
server/vm : ActionExec.cpp ActionExec.h
testsuite/swfdec: PASSING
Log message:
* gui/gui.cpp (restart): call movie_root::reset so scripts are
enabled
again; (getMovieInfo): add info about wheter scripts are
disabled.
* server/movie_root.{cpp,h}: add disableScripts and
scriptsDisabled
methods; don't process queued actions if scripts are disabled,
disable scripts if ActionLimitException is thrown by
execution of
an executable code.
* server/vm/ActionExec.{cpp,h}: re-throw ActionLimitException
so all
elements of the call stack have a chance to cleanup and the
exception
is eventually cought by the movie_root.
* testsuite/swfdec/PASSING: success with script abortion tests.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4500&r2=1.4501
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.104&r2=1.105
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.103&r2=1.104
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.h?cvsroot=gnash&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.cpp?cvsroot=gnash&r1=1.55&r2=1.56
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ActionExec.h?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.33&r2=1.34
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4500
retrieving revision 1.4501
diff -u -b -r1.4500 -r1.4501
--- ChangeLog 2 Oct 2007 13:17:29 -0000 1.4500
+++ ChangeLog 2 Oct 2007 15:44:50 -0000 1.4501
@@ -1,5 +1,17 @@
2007-10-02 Sandro Santilli <address@hidden>
+ * gui/gui.cpp (restart): call movie_root::reset so scripts are enabled
+ again; (getMovieInfo): add info about wheter scripts are disabled.
+ * server/movie_root.{cpp,h}: add disableScripts and scriptsDisabled
+ methods; don't process queued actions if scripts are disabled,
+ disable scripts if ActionLimitException is thrown by execution of
+ an executable code.
+ * server/vm/ActionExec.{cpp,h}: re-throw ActionLimitException so all
+ elements of the call stack have a chance to cleanup and the exception
+ is eventually cought by the movie_root.
+ * testsuite/swfdec/PASSING: success with script abortion tests.
+
+2007-10-02 Sandro Santilli <address@hidden>
* server/asobj/xml.{cpp,h}: get environment passed for events
invocation purposes.
Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -b -r1.104 -r1.105
--- gui/gui.cpp 1 Oct 2007 22:04:41 -0000 1.104
+++ gui/gui.cpp 2 Oct 2007 15:44:51 -0000 1.105
@@ -154,7 +154,7 @@
{
// GNASH_REPORT_FUNCTION;
- _stage->clear();
+ _stage->reset();
_started = false;
start();
@@ -751,6 +751,7 @@
snprintf(buf, 16, "SWF%d", def0->get_version()); buf[15] = '\0';
ret->insert(ret->begin(), StringPair("_level0 SWFVersion", string(buf)));
ret->insert(ret->begin(), StringPair("_level0 URL", def0->get_url()));
+ ret->insert(ret->begin(), StringPair("Stage scripts",
stage.scriptsDisabled() ? " disabled" : "enabled"));
return ret;
}
Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -b -r1.103 -r1.104
--- server/movie_root.cpp 2 Oct 2007 06:26:43 -0000 1.103
+++ server/movie_root.cpp 2 Oct 2007 15:44:51 -0000 1.104
@@ -33,6 +33,7 @@
#include "utility.h"
#include "URL.h"
#include "namedStrings.h"
+#include "GnashException.h"
#ifdef NEW_KEY_LISTENER_LIST_DESIGN
#include "action.h"
#endif
@@ -83,12 +84,40 @@
m_time_remainder(0.0f),
m_drag_state(),
_allowRescale(true),
- _invalidated(true)
+ _invalidated(true),
+ _disableScripts(false)
{
}
+void
+movie_root::disableScripts()
+{
+ _disableScripts=true;
+
+ // NOTE: we won't clear the action queue now
+ // to avoid invalidating iterators as we've
+ // been probably called during processing
+ // of the queue.
+ //
+ //clearActionQueue();
+}
+
+void
+movie_root::clearActionQueue()
+{
+ for (ActionQueue::iterator it=_actionQueue.begin(),
+ itE=_actionQueue.end();
+ it != itE; ++it)
+ {
+ delete *it;
+ }
+ _actionQueue.clear();
+}
+
movie_root::~movie_root()
{
+ clearActionQueue();
+
for (ActionQueue::iterator it=_actionQueue.begin(),
itE=_actionQueue.end();
it != itE; ++it)
@@ -187,6 +216,13 @@
}
void
+movie_root::reset()
+{
+ clear();
+ _disableScripts = false;
+}
+
+void
movie_root::clear()
{
// wipe out live chars
@@ -1071,13 +1107,31 @@
if ( actionsToProcess ) log_msg(" Processing action queue (call %u)",
calls);
#endif
+ if ( _disableScripts )
+ {
+ //log_debug(_("Scripts are disabled, global instance list has
%d elements"), _liveChars.size());
+ /// cleanup anything pushed later..
+ clearActionQueue();
+ return;
+ }
+
// _actionQueue may be changed due to actions (appended-to)
// this loop might be optimized by using an iterator
// and a final call to .clear()
while ( ! _actionQueue.empty() )
{
ExecutableCode* code = _actionQueue.front();
+ try
+ {
code->execute();
+ }
+ catch (ActionLimitException& al)
+ {
+ log_error(_("ActionLimits hit: %s"), al.what());
+ disableScripts();
+ clearActionQueue();
+ break;
+ }
_actionQueue.pop_front();
delete code;
}
Index: server/movie_root.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.h,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- server/movie_root.h 1 Oct 2007 22:41:59 -0000 1.79
+++ server/movie_root.h 2 Oct 2007 15:44:51 -0000 1.80
@@ -15,7 +15,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: movie_root.h,v 1.79 2007/10/01 22:41:59 strk Exp $ */
+/* $Id: movie_root.h,v 1.80 2007/10/02 15:44:51 strk Exp $ */
/// \page events_handling Handling of user events
///
@@ -568,8 +568,31 @@
///
void clear();
+ /// Reset stage to it's initial state
+ //
+ void reset();
+
+ /// Call this method for disabling run of actions
+ //
+ /// NOTE: this will only work for queued actions, not
+ /// for *every* action. Supposedly all actions should
+ /// be queued, but this is not really always the case.
+ /// Notable exceptions are:
+ /// - Actions in callFrame target frame
+ /// but only executed by execution of the callFrame opcode
+ /// - on{,Clip}{Initialize,Construct} event handlers
+ /// - User event handlers (mouse,keyboard)
+ ///
+ void disableScripts();
+
+ /// Return true if scripts execution is disabled
+ bool scriptsDisabled() const { return _disableScripts; };
+
private:
+ /// Delete all elements on the action queue and empty it.
+ void clearActionQueue();
+
/// An element of the advanceable characters
typedef boost::intrusive_ptr<character> AdvanceableCharacter;
@@ -766,6 +789,9 @@
/// See setInvalidated
bool _invalidated;
+ /// This is set to true if execution of scripts
+ /// aborted due to action limit set or whatever else
+ bool _disableScripts;
};
Index: server/vm/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- server/vm/ActionExec.cpp 1 Oct 2007 16:51:18 -0000 1.55
+++ server/vm/ActionExec.cpp 2 Oct 2007 15:44:51 -0000 1.56
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: ActionExec.cpp,v 1.55 2007/10/01 16:51:18 strk Exp $ */
+/* $Id: ActionExec.cpp,v 1.56 2007/10/02 15:44:51 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -34,6 +34,7 @@
#include "ASHandlers.h"
#include "as_environment.h"
#include "debugger.h"
+#include "WallClockTimer.h"
#include <typeinfo>
#include <boost/algorithm/string/case_conv.hpp>
@@ -177,6 +178,9 @@
// TODO: specify in the .gnashrc !!
static const size_t maxBranchCount = 65536; // what's enough ?
+ uint32_t timeLimit = getScriptTimeout();
+ WallClockTimer timer;
+
size_t branchCount = 0;
try {
while (1) // We might not stop at stop_pc, if we are trying.
@@ -387,10 +391,19 @@
// Control flow actions will change the PC (next_pc)
pc = next_pc;
- // Check for loop backs. Actually this should be implemented
- // as a timeout in seconds.
+ // Check for script limits hit.
// See: http://www.gnashdev.org/wiki/index.php/ScriptLimits
//
+#if 0
+ // TODO: only check on branch-back ? (would be less aggressive..)
+ // WARNING: if the movie is stopped, the wall clock continues to run !
+ if ( timeLimit && timer.elapsed() > timeLimit )
+ {
+ char buf[256];
+ snprintf(buf, 255, _("Script exceeded time limit of %u
milliseconds."), timeLimit);
+ throw ActionLimitException(buf);
+ }
+#else
if ( pc <= oldPc )
{
if ( ++branchCount > maxBranchCount )
@@ -402,20 +415,20 @@
}
//log_debug("Branch count: %u", branchCount);
}
+#endif
}
}
catch (ActionLimitException& ex)
{
- // We want to always show these messages, as in the future
- // we'll eventually need to pop up a window asking user about
- // what to do instead..
- //
- //IF_VERBOSE_ASCODING_ERRORS (
- log_aserror("Script aborted due to exceeded limit: %s", ex.what());
- //)
+ // Here's were we should pop-up a window to prompt user about
+ // what to do next (abort or not ?)
+ //log_error("Script aborted due to exceeded limit: %s - cleaning up
after run", ex.what());
+ cleanupAfterRun(true); // we expect inconsistencies here
+ throw;
}
+ // TODO: catch other exceptions ?
cleanupAfterRun();
@@ -423,7 +436,7 @@
/*private*/
void
-ActionExec::cleanupAfterRun()
+ActionExec::cleanupAfterRun(bool expectInconsistencies)
{
assert(_original_target);
env.set_target(_original_target);
@@ -436,16 +449,18 @@
{
if ( currCallStackDepth > _initialCallStackDepth )
{
+ if ( ! expectInconsistencies )
+ {
// TODO: try to produce this error hitting script limits
log_error(_("Call stack at end of ActionScript execution "
"(" SIZET_FMT ") exceeds call stack depth at start "
"of it (" SIZET_FMT ") - limits hit ?"),
currCallStackDepth, _initialCallStackDepth);
- size_t diff = currCallStackDepth-_initialCallStackDepth;
- while (diff--)
- {
- env.popCallFrame();
}
+ size_t diff = currCallStackDepth-_initialCallStackDepth;
+ // TODO: implement dropCallFrames(diff) ?
+ while (diff--) env.popCallFrame();
+ assert(env.callStackDepth() == _initialCallStackDepth);
}
else
{
@@ -467,13 +482,18 @@
env.push(as_value());
}
} else if ( _initial_stack_size < env.stack_size() ) {
+ if ( ! expectInconsistencies )
+ {
// We can argue this would be an "size-optimized" SWF instead...
IF_VERBOSE_MALFORMED_SWF(
log_swferror(_(SIZET_FMT " elements left on the stack after block
execution. "
"Cleaning up"), env.stack_size()-_initial_stack_size);
);
+ }
env.drop(env.stack_size()-_initial_stack_size);
}
+
+ //log_debug("After cleanup of ActionExec %p, env %p has stack size of %d
and callStackDepth of %d", (void*)this, (void*)&env, env.stack_size(),
env.callStackDepth());
}
void
@@ -740,6 +760,15 @@
return _function_var ? _this_ptr.get() : env.get_original_target();
}
+uint32_t
+ActionExec::getScriptTimeout()
+{
+ // TODO1: allow specifying this in the .gnashrc file
+ // TODO2: possibly use the SWF tag for this
+ return 15000;
+ //return 2000;
+}
+
} // end of namespace gnash
Index: server/vm/ActionExec.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ActionExec.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/vm/ActionExec.h 30 Sep 2007 05:24:36 -0000 1.24
+++ server/vm/ActionExec.h 2 Oct 2007 15:44:51 -0000 1.25
@@ -118,7 +118,7 @@
/// Run after a complete run, or after an run interrupted by
/// a bail-out exception (ActionLimitException, for example)
- void cleanupAfterRun();
+ void cleanupAfterRun(bool expectInconsistencies=false);
/// the 'with' stack associated with this execution thread
std::vector<with_stack_entry> with_stack;
@@ -184,6 +184,10 @@
bool _abortOnUnload;
+ /// Return the number of milliseconds after which
+ /// execution of a script block should abort.
+ uint32_t getScriptTimeout();
+
public:
/// \brief
Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- testsuite/swfdec/PASSING 27 Sep 2007 22:20:08 -0000 1.33
+++ testsuite/swfdec/PASSING 2 Oct 2007 15:44:51 -0000 1.34
@@ -254,3 +254,8 @@
string-trace-5.swf
string-trace-6.swf
string-trace-7.swf
+abort-really-aborts-6.swf
+abort-really-aborts-7.swf
+stack-overflow-5.swf
+stack-overflow-6.swf
+stack-overflow-7.swf