Compare commits

1 Commits
main ... 1.1

6 changed files with 736 additions and 1095 deletions

View File

@@ -1,177 +0,0 @@
From 79079a0c6df5e02c4c47003fb88656c37aaf3d0a Mon Sep 17 00:00:00 2001
From: Sami Shalayel <sami.shalayel@qt.io>
Date: Thu, 5 Jun 2025 10:51:46 +0200
Subject: [PATCH] qmlcachegen: fix crash on unresolved type with required
property
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
qmlcachegen can't resolve all types when importing QtQuick.Controls, so
scopes from QtQuick.Controls might be unresolved.
Check the scope before creating a fix suggesion when checking the
required properties, and add a test that tests a file with required
properties on an unresolved base type "Tumbler".
This also fixes the crashes from QTBUG-137196 and QTBUG-136998 it seems.
Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-137411
Fixes: QTBUG-137196
Fixes: QTBUG-136998
Change-Id: Ibf461b54abf84ba13bff8c4833940c7359cf2d8e
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit c9713681e8d0ee7b7a69d38c5972ee73e8ee4b78)
---
src/qmlcompiler/qqmljsimportvisitor.cpp | 21 ++++----
.../data/crashes/buggyFixSuggestion.qml | 25 +++++++++
.../auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 54 +++++++++++++++++++
3 files changed, 90 insertions(+), 10 deletions(-)
create mode 100644 tests/auto/qml/qmlcachegen/data/crashes/buggyFixSuggestion.qml
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index 2a1f31e..e2371a5 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -1041,16 +1041,17 @@ void QQmlJSImportVisitor::checkRequiredProperties()
: u"here"_s;
if (!prevRequiredScope.isNull()) {
- auto sourceScope = prevRequiredScope->baseType();
- suggestion = QQmlJSFixSuggestion{
- "%1:%2:%3: Property marked as required in %4."_L1
- .arg(sourceScope->filePath())
- .arg(sourceScope->sourceLocation().startLine)
- .arg(sourceScope->sourceLocation().startColumn)
- .arg(requiredScopeName),
- sourceScope->sourceLocation()
- };
- suggestion->setFilename(sourceScope->filePath());
+ if (auto sourceScope = prevRequiredScope->baseType()) {
+ suggestion = QQmlJSFixSuggestion{
+ "%1:%2:%3: Property marked as required in %4."_L1
+ .arg(sourceScope->filePath())
+ .arg(sourceScope->sourceLocation().startLine)
+ .arg(sourceScope->sourceLocation().startColumn)
+ .arg(requiredScopeName),
+ sourceScope->sourceLocation()
+ };
+ suggestion->setFilename(sourceScope->filePath());
+ }
} else {
message += " (marked as required by %1)"_L1.arg(requiredScopeName);
}
diff --git a/tests/auto/qml/qmlcachegen/data/crashes/buggyFixSuggestion.qml b/tests/auto/qml/qmlcachegen/data/crashes/buggyFixSuggestion.qml
new file mode 100644
index 0000000..f435d2e
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/data/crashes/buggyFixSuggestion.qml
@@ -0,0 +1,25 @@
+import QtQuick
+
+Item {
+ id: root
+
+ Item {
+ id: inner
+
+ Tumbler {
+ id: year
+
+ delegate: Rectangle {
+ required property var modelData
+ }
+ }
+
+ Tumbler {
+ id: month
+
+ delegate: Rectangle {
+ required property var modelData
+ }
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index 3c602f5..bb8fc5c 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -73,6 +73,9 @@ private slots:
void aotstatsSerialization();
void aotstatsGeneration_data();
void aotstatsGeneration();
+
+ void crash_data();
+ void crash();
};
// A wrapper around QQmlComponent to ensure the temporary reference counts
@@ -121,6 +124,36 @@ static bool generateCache(const QString &qmlFileName, QByteArray *capturedStderr
return proc.exitCode() == 0;
}
+static bool generateCpp(const QString &qmlFileName, QByteArray *capturedStderr = nullptr)
+{
+#if defined(QTEST_CROSS_COMPILED)
+ QTest::qFail("You cannot call qmlcachegen on the target.", __FILE__, __LINE__);
+ return false;
+#endif
+ QProcess proc;
+ if (capturedStderr == nullptr)
+ proc.setProcessChannelMode(QProcess::ForwardedChannels);
+ proc.setProgram(QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath)
+ + QLatin1String("/qmlcachegen"));
+ QTemporaryDir outputDir;
+ const QString outputFile = outputDir.filePath("output.cpp"_L1);
+ proc.setArguments(QStringList{ "--resource-path"_L1, "qrc:/qt/qml/Crashes/testFile.qml"_L1,
+ "-o"_L1, outputFile, qmlFileName });
+ proc.start();
+ if (!proc.waitForFinished())
+ return false;
+
+ if (capturedStderr)
+ *capturedStderr = proc.readAllStandardError();
+
+ if (!QFile::exists(outputFile))
+ return false;
+
+ if (proc.exitStatus() != QProcess::NormalExit)
+ return false;
+ return proc.exitCode() == 0;
+}
+
tst_qmlcachegen::tst_qmlcachegen()
: QQmlDataTest(QT_QMLTEST_DATADIR)
{
@@ -1023,6 +1056,27 @@ void tst_qmlcachegen::aotstatsGeneration()
}
}
+void tst_qmlcachegen::crash_data()
+{
+ QTest::addColumn<QString>("fileName");
+
+ QTest::addRow("buggyFixSuggestion") << u"buggyFixSuggestion.qml"_s;
+}
+
+void tst_qmlcachegen::crash()
+{
+#if defined(QTEST_CROSS_COMPILED)
+ QSKIP("Cannot call qmlcachegen on cross-compiled target.");
+#endif
+
+ QFETCH(QString, fileName);
+ const QString filePath = testFile("crashes/" + fileName);
+
+ QFile file(filePath);
+ QVERIFY(file.exists());
+ QVERIFY(generateCpp(filePath));
+}
+
const QQmlScriptString &ScriptStringProps::undef() const
{
return m_undef;
--
2.49.0

View File

@@ -2,20 +2,10 @@
<constraints>
<hardware>
<disk>
<size unit="G">25</size>
<size unit="G">20</size>
</disk>
<processors>4</processors>
</hardware>
<overwrite>
<conditions>
<arch>s390x</arch>
</conditions>
<hardware>
<memory>
<size unit="G">9</size>
</memory>
</hardware>
</overwrite>
<overwrite>
<conditions>
<arch>ppc64</arch>
@@ -45,7 +35,7 @@
</conditions>
<hardware>
<disk>
<size unit="G">3</size>
<size unit="G">2</size>
</disk>
<memory>
<size unit="G">2</size>

View File

@@ -1,126 +1,3 @@
-------------------------------------------------------------------
Sun Jun 8 14:52:28 UTC 2025 - Christophe Marin <christophe@krop.fr>
- Add upstream fix (QTBUG-137196):
* 0001-qmlcachegen-fix-crash-on-unresolved-type-with-requir.patch
-------------------------------------------------------------------
Tue Jun 3 07:49:26 UTC 2025 - Christophe Marin <christophe@krop.fr>
- Update to 6.9.1:
* https://www.qt.io/blog/qt-6.9.1-released
- Drop patch, merged upstream:
* 0001-do-not-re-resolve-iterator-value-types.patch
-------------------------------------------------------------------
Wed Apr 30 12:42:32 UTC 2025 - Hillwood Yang <hillwood@opensuse.org>
- Add 0001-do-not-re-resolve-iterator-value-types.patch
We've resolved the value type in the type propagator. Trying to do it
again in the code generator, after the iterator may have been adjusted,
is quite wrong. If we resolve the list value type on a type that's not
a list (anymore), then we get an invalid type, which subsequently
crashes.
-------------------------------------------------------------------
Wed Apr 2 11:03:36 UTC 2025 - Christophe Marin <christophe@krop.fr>
- Update to 6.9.0:
* https://www.qt.io/blog/qt-6.9-released
-------------------------------------------------------------------
Fri Jan 31 10:22:53 UTC 2025 - Christophe Marin <christophe@krop.fr>
- Update to 6.8.2
https://www.qt.io/blog/qt-6.8.2-released
- Drop patch, merged upstream:
* 0001-CMake-Fix-find_package-call-in-Qt6QmlFindQmlscIntern.patch
-------------------------------------------------------------------
Sat Jan 18 15:34:27 UTC 2025 - Christophe Marin <christophe@krop.fr>
- Add patch to fix qmlsc detection:
* 0001-CMake-Fix-find_package-call-in-Qt6QmlFindQmlscIntern.patch
-------------------------------------------------------------------
Mon Dec 2 13:02:02 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.8.1:
* https://www.qt.io/blog/qt-6.8.1-released
- Drop patches, merged upstream:
* 0001-Revert-QQmlDelegateModel-fix-delegates-not-being-cre.patch
* 0002-QQmlDelegateModel-fix-delegates-not-being-created-in.patch
* 0001-Compiler-Wrap-raw-string-literals-in-QStringLiteral-.patch
* 0001-QQuickItemView-fix-crash-with-zero-size-SwipeView-th.patch
* 0001-QQuickAccessibleAttached-Let-implicit-names-work-whe.patch
* 0001-QQuickItem-map-To-From-Item-Account-for-not-having-a.patch
* 0001-Log-state-transitions-for-the-GC.patch
* 0001-Engine-Mark-created-wrapped-objects-after-GCState-Ma.patch
-------------------------------------------------------------------
Tue Nov 12 15:40:15 UTC 2024 - Fabian Vogt <fvogt@suse.com>
- Replace 0001-WIP-speculative-gc-fix.patch with newer ones,
should unbreak spectacle and some others (kde#496139):
* 0001-Log-state-transitions-for-the-GC.patch
* 0001-Engine-Mark-created-wrapped-objects-after-GCState-Ma.patch
-------------------------------------------------------------------
Wed Nov 6 19:20:07 UTC 2024 - Fabian Vogt <fvogt@suse.com>
- Add patch (pending upstream) to fix properties getting GC'd:
(QTBUG-128789, kde#494804)
* 0001-WIP-speculative-gc-fix.patch
-------------------------------------------------------------------
Mon Nov 4 17:50:07 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Add upstream change (QTBUG-129500, kde#495089):
* 0001-QQuickItem-map-To-From-Item-Account-for-not-having-a.patch
-------------------------------------------------------------------
Fri Oct 25 11:42:28 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Add upstream changes:
* 0001-QQuickItemView-fix-crash-with-zero-size-SwipeView-th.patch
(QTBUG-129622, kde#493854)
* 0001-QQuickAccessibleAttached-Let-implicit-names-work-whe.patch
(QTBUG-130360)
-------------------------------------------------------------------
Tue Oct 15 09:37:16 UTC 2024 - Antonio Larrosa <alarrosa@suse.com>
- Update memory constraints for s390x and use %limit_build
-------------------------------------------------------------------
Tue Oct 15 07:52:36 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update disk constraints
-------------------------------------------------------------------
Wed Oct 9 16:52:34 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Add upstream change to fix compilation failures (kde#494281, QTBUG-129797)
* 0001-Compiler-Wrap-raw-string-literals-in-QStringLiteral-.patch
-------------------------------------------------------------------
Tue Oct 8 10:17:37 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.8.0:
* https://www.qt.io/blog/qt-6.8-released
- Add upstream changes:
* 0001-Revert-QQmlDelegateModel-fix-delegates-not-being-cre.patch
* 0002-QQmlDelegateModel-fix-delegates-not-being-created-in.patch
(kde#493116, QTBUG-127340)
- Merge some -devel and -private-devel packages that only have
private API.
-------------------------------------------------------------------
Sat Sep 28 08:22:56 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Update to 6.7.3
* https://www.qt.io/blog/qt-6.7.3-released
-------------------------------------------------------------------
Wed Jun 19 07:25:41 UTC 2024 - Christophe Marin <christophe@krop.fr>

File diff suppressed because it is too large Load Diff

BIN
qtdeclarative-everywhere-src-6.7.2.tar.xz (Stored with Git LFS) Normal file

Binary file not shown.

BIN
qtdeclarative-everywhere-src-6.9.1.tar.xz (Stored with Git LFS)

Binary file not shown.