Fix crash when loading cache files generated ahead of time

The offset of the runtimeStrings array differed between a V4_BOOTSTRAP build
and the regular library build. This is an intermediate fix until QTBUG-58666
is fixed properly.

Change-Id: Id1310ffa82f1079c1acef7730db41186fa62610f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Simon Hausmann 2017-03-06 15:06:59 +01:00
parent d5d12e1d6f
commit 84a07bebc9
4 changed files with 11 additions and 9 deletions

View File

@ -95,8 +95,8 @@ static QString cacheFilePath(const QUrl &url)
#ifndef V4_BOOTSTRAP
CompilationUnit::CompilationUnit()
: data(0)
, engine(0)
, runtimeStrings(0)
, engine(0)
, runtimeLookups(0)
, runtimeRegularExpressions(0)
, runtimeClasses(0)

View File

@ -816,13 +816,11 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount
// Called only when building QML, when we build the header for JS first and append QML data
virtual QV4::CompiledData::Unit *createUnitData(QmlIR::Document *irDocument);
#ifndef V4_BOOTSTRAP
ExecutionEngine *engine;
#endif
QV4::Heap::String **runtimeStrings; // Array
#ifndef V4_BOOTSTRAP
ExecutionEngine *engine;
QString fileName() const { return data->stringAt(data->sourceFileIndex); }
QUrl url() const { if (m_url.isNull) m_url = QUrl(fileName()); return m_url; }

View File

@ -42,6 +42,7 @@
#include "qqmldebugserviceinterfaces_p.h"
#include <private/qqmlengine_p.h>
#include <private/qv4compileddata_p.h>
QT_BEGIN_NAMESPACE
@ -181,12 +182,12 @@ bool QQmlDebuggingEnabler::startDebugConnector(const QString &pluginName,
return connector ? connector->open(configuration) : false;
}
enum { HookCount = 3 };
enum { HookCount = 4 };
// Only add to the end, and bump version if you do.
quintptr Q_QML_EXPORT qtDeclarativeHookData[] = {
// Version of this Array. Bump if you add to end.
1,
2,
// Number of entries in this array.
HookCount,
@ -194,7 +195,10 @@ quintptr Q_QML_EXPORT qtDeclarativeHookData[] = {
// TypeInformationVersion, an integral value, bumped whenever private
// object sizes or member offsets that are used in Qt Creator's
// data structure "pretty printing" change.
2
3,
// Version of the cache data.
QV4_DATA_STRUCTURE_VERSION
};
Q_STATIC_ASSERT(HookCount == sizeof(qtDeclarativeHookData) / sizeof(qtDeclarativeHookData[0]));

View File

@ -109,7 +109,7 @@ void tst_toolsupport::offsets_data()
= QTest::newRow("CompiledData::CompilationUnit::runtimeStrings")
<< pmm_to_offsetof(&QV4::CompiledData::CompilationUnit::runtimeStrings);
data << 16 << 32;
data << 12 << 24;
}
{