Qt Declarative (Quick 2)
Go to file
Simon Hausmann 729cde5578 Fix crashes when running tst_qqmlecmascript::importScripts with aggressive gc
In the case of imported JavaScript files, it may happen that we parse the JS once
and then re-use it across different places where it is imported. That means we
parse and compile the JS once, keep the QV4::Script around and call it as a function
closure with different qml global objects (contexts), depending on where it is
imported from.

In this situation it is possible that the QV4::Script's run() is called once, a
new function object is created, we call it to return the JS library to "eval"
itself into the qml scope and afterwards it may happen that the function object
is garbage collected.  It is at this point possible that the compilation unit's
refcount therefore also drops to zero, and thus subsequent calls to
QV4::Script::run() that create new QQmlBinding objects will access a dangling
compilationUnit pointer.

This patch fixes that by making QV4::Script - which is holding a QV4::Function
pointer - also have a persistent, which maintainers a refcount on the
compilation unit.  If the script dies, the persistent will get collected and
the last deref will delete the unit. A script can however outlive the engine,
but PersistentValue has the mechanism built in to free itself on engine
destruction, which will also deref the unit accordingly.

Change-Id: I0a7f4e64497bde423ffa55c705af55cdb7d29cf2
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2013-09-02 14:32:20 +02:00
bin Update copyright year in Digia's license headers 2013-01-10 19:52:37 +01:00
dist New scenegraph renderer and atlas textures. 2013-09-02 14:24:36 +02:00
examples Merge remote-tracking branch 'origin/stable' into dev 2013-08-19 09:47:35 +02:00
src Fix crashes when running tst_qqmlecmascript::importScripts with aggressive gc 2013-09-02 14:32:20 +02:00
tests New scenegraph renderer and atlas textures. 2013-09-02 14:24:36 +02:00
tools Fix crashes when running tst_qqmlecmascript::importScripts with aggressive gc 2013-09-02 14:32:20 +02:00
.gitattributes Update the git-archive export options 2012-09-10 14:24:05 +02:00
.gitignore Revert "Simplify JS bindings generation" 2013-06-13 14:17:03 +02:00
.gitmodules Prospective fix for builds in the CI system on Windows machines 2013-08-07 11:51:25 +02:00
.qmake.conf Bump MODULE_VERSION to 5.1.2 2013-07-24 00:07:54 +02:00
.tag Update the git-archive export options 2012-09-10 14:24:05 +02:00
LGPL_EXCEPTION.txt Add license files mandated by (L)GPL. 2013-02-15 00:03:10 +01:00
LICENSE.FDL Add license files mandated by (L)GPL. 2013-02-15 00:03:10 +01:00
LICENSE.GPL Add license files mandated by (L)GPL. 2013-02-15 00:03:10 +01:00
LICENSE.LGPL Add license files mandated by (L)GPL. 2013-02-15 00:03:10 +01:00
qtdeclarative.pro Enable QtDeclarative for iOS 2013-08-07 11:52:20 +02:00
sync.profile Fix generation of headers by syncqt.pl outside git builds 2013-09-02 08:32:54 +02:00