Merge lp:~timo-jyrinki/kubuntu-packaging/qtdeclarative_crashers_fixes_trigger_CI into lp:~kubuntu-packagers/kubuntu-packaging/qtdeclarative-opensource-src

Proposed by Timo Jyrinki
Status: Merged
Merged at revision: 173
Proposed branch: lp:~timo-jyrinki/kubuntu-packaging/qtdeclarative_crashers_fixes_trigger_CI
Merge into: lp:~kubuntu-packagers/kubuntu-packaging/qtdeclarative-opensource-src
Diff against target: 275 lines (+250/-0)
4 files modified
debian/changelog (+9/-0)
debian/patches/Avoid-race-condition-in-QQmlEngine-on-shutdown.patch (+84/-0)
debian/patches/Fix-crashes-when-calling-Array.sort-with-imperfect-s.patch (+155/-0)
debian/patches/series (+2/-0)
To merge this branch: bzr merge lp:~timo-jyrinki/kubuntu-packaging/qtdeclarative_crashers_fixes_trigger_CI
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Timo Jyrinki Approve
Review via email: mp+243974@code.launchpad.net

Commit message

* debian/patches/Avoid-race-condition-in-QQmlEngine-on-shutdown.patch
  - Cherry-pick an app shutdown crash fix (LP: #1373039)
* debian/patches/Fix-crashes-when-calling-Array.sort-with-imperfect-s.patch
  - Cherry-pick a fix for a crasher in Array.sort (LP: #1295119)

Description of the change

This MP got released already, MP done to get the CI triggered for updated code coverage numbers.

To post a comment you must log in.
Revision history for this message
Timo Jyrinki (timo-jyrinki) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Let's try one more time. Already merged, but CI has fixed some e-mail issues in the infrastructure.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Ok giving up, now it's broken since it's looking at the (obsolete) qt5-beta2 PPA.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-10-27 05:58:19 +0000
+++ debian/changelog 2014-12-08 11:05:28 +0000
@@ -1,3 +1,12 @@
1qtdeclarative-opensource-src (5.3.2-3ubuntu2) vivid; urgency=medium
2
3 * debian/patches/Avoid-race-condition-in-QQmlEngine-on-shutdown.patch
4 - Cherry-pick an app shutdown crash fix (LP: #1373039)
5 * debian/patches/Fix-crashes-when-calling-Array.sort-with-imperfect-s.patch
6 - Cherry-pick a fix for a crasher in Array.sort (LP: #1295119)
7
8 -- Timo Jyrinki <timo-jyrinki@ubuntu.com> Wed, 03 Dec 2014 08:32:46 +0000
9
1qtdeclarative-opensource-src (5.3.2-3ubuntu1) vivid; urgency=medium10qtdeclarative-opensource-src (5.3.2-3ubuntu1) vivid; urgency=medium
211
3 * New upstream release.12 * New upstream release.
413
=== added file 'debian/patches/Avoid-race-condition-in-QQmlEngine-on-shutdown.patch'
--- debian/patches/Avoid-race-condition-in-QQmlEngine-on-shutdown.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/Avoid-race-condition-in-QQmlEngine-on-shutdown.patch 2014-12-08 11:05:28 +0000
@@ -0,0 +1,84 @@
1From 48d93e0d854b3f9a2486a2393fee38496fd57bd9 Mon Sep 17 00:00:00 2001
2From: Gunnar Sletta <gunnar.sletta@jollamobile.com>
3Date: Tue, 1 Jul 2014 14:48:07 +0200
4Subject: [PATCH] Avoid race condition in QQmlEngine on shutdown.
5
6The QQmlTypeLoader was deleted (and its thread shut down) when
7the QQmlEnginePrivate was destroyed. However, the QQmlTypeLoader
8runs a thread which would happiliy make calls on the engine and
9its managed data. Fix this by stopping the QQmlTypeLoader's
10thread right away in QQmlEngine.
11
12Task-number: QTBUG-39905
13Change-Id: Ida8e95d083f79237c74b036fd3521133a9fa4ac7
14Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
15---
16 src/qml/qml/qqmlengine.cpp | 2 ++
17 src/qml/qml/qqmltypeloader.cpp | 15 ++++++++++++---
18 src/qml/qml/qqmltypeloader_p.h | 1 +
19 3 files changed, 15 insertions(+), 3 deletions(-)
20
21diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
22index 17e5c55..46fc329 100644
23--- a/src/qml/qml/qqmlengine.cpp
24+++ b/src/qml/qml/qqmlengine.cpp
25@@ -904,6 +904,8 @@ QQmlEngine::~QQmlEngine()
26 if (d->isDebugging)
27 QQmlDebugServer::instance()->removeEngine(this);
28
29+ d->typeLoader.invalidate();
30+
31 // Emit onDestruction signals for the root context before
32 // we destroy the contexts, engine, Singleton Types etc. that
33 // may be required to handle the destruction signal.
34diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
35index 1afc5bb..c5a4d65 100644
36--- a/src/qml/qml/qqmltypeloader.cpp
37+++ b/src/qml/qml/qqmltypeloader.cpp
38@@ -897,11 +897,20 @@ QQmlDataLoader::QQmlDataLoader(QQmlEngine *engine)
39 /*! \internal */
40 QQmlDataLoader::~QQmlDataLoader()
41 {
42+ invalidate();
43+}
44+
45+void QQmlDataLoader::invalidate()
46+{
47 for (NetworkReplies::Iterator iter = m_networkReplies.begin(); iter != m_networkReplies.end(); ++iter)
48 (*iter)->release();
49+ m_networkReplies.clear();
50
51- shutdownThread();
52- delete m_thread;
53+ if (m_thread) {
54+ shutdownThread();
55+ delete m_thread;
56+ m_thread = 0;
57+ }
58 }
59
60 void QQmlDataLoader::lock()
61@@ -1228,7 +1237,7 @@ void QQmlDataLoader::setCachedUnit(QQmlDataBlob *blob, const QQmlPrivate::Cached
62
63 void QQmlDataLoader::shutdownThread()
64 {
65- if (!m_thread->isShutdown())
66+ if (m_thread && !m_thread->isShutdown())
67 m_thread->shutdown();
68 }
69
70diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
71index b09ac15..3d0b77e 100644
72--- a/src/qml/qml/qqmltypeloader_p.h
73+++ b/src/qml/qml/qqmltypeloader_p.h
74@@ -233,6 +233,7 @@ public:
75
76 QQmlEngine *engine() const;
77 void initializeEngine(QQmlExtensionInterface *, const char *);
78+ void invalidate();
79
80 protected:
81 void shutdownThread();
82--
832.1.3
84
085
=== added file 'debian/patches/Fix-crashes-when-calling-Array.sort-with-imperfect-s.patch'
--- debian/patches/Fix-crashes-when-calling-Array.sort-with-imperfect-s.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/Fix-crashes-when-calling-Array.sort-with-imperfect-s.patch 2014-12-08 11:05:28 +0000
@@ -0,0 +1,155 @@
1From 210475565969ca5381174016b47cd32ddc96eaed Mon Sep 17 00:00:00 2001
2From: Lars Knoll <lars.knoll@digia.com>
3Date: Thu, 12 Jun 2014 14:35:53 +0200
4Subject: [PATCH] Fix crashes when calling Array.sort with imperfect sort
5 functions
6
7We can't use std::sort to implement Array.sort. The reason is that
8std::sort expects a conformant compare function, and can do weird
9things (esp. crash) when the sort function isn't conformant.
10
11Falling back to qSort is not possible, as the method has been
12deprecated. So add a copy of the qSort implementation here, and
13use that one instead.
14
15Fix the sortint test in tst_qqmlecmascript to have a consistent
16sort function for strings, as the result of calling sort is
17otherwise undefined according to the ecma standard.
18
19Task-number: QTBUG-39072
20Change-Id: I0602b3aa1ffa4de5006da58396f166805cf4a5e2
21Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
22Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
23---
24 src/qml/jsruntime/qv4arraydata.cpp | 56 +++++++++++++++++++++-
25 tests/auto/qml/qjsengine/tst_qjsengine.cpp | 19 ++++++++
26 .../auto/qml/qqmlecmascript/data/sequenceSort.qml | 2 +-
27 3 files changed, 75 insertions(+), 2 deletions(-)
28
29diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
30index 7d76a10..9627848 100644
31--- a/src/qml/jsruntime/qv4arraydata.cpp
32+++ b/src/qml/jsruntime/qv4arraydata.cpp
33@@ -674,6 +674,60 @@ bool ArrayElementLessThan::operator()(Value v1, Value v2) const
34 return p1s->toQString() < p2s->toQString();
35 }
36
37+template <typename RandomAccessIterator, typename T, typename LessThan>
38+void sortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
39+{
40+top:
41+ int span = int(end - start);
42+ if (span < 2)
43+ return;
44+
45+ --end;
46+ RandomAccessIterator low = start, high = end - 1;
47+ RandomAccessIterator pivot = start + span / 2;
48+
49+ if (lessThan(*end, *start))
50+ qSwap(*end, *start);
51+ if (span == 2)
52+ return;
53+
54+ if (lessThan(*pivot, *start))
55+ qSwap(*pivot, *start);
56+ if (lessThan(*end, *pivot))
57+ qSwap(*end, *pivot);
58+ if (span == 3)
59+ return;
60+
61+ qSwap(*pivot, *end);
62+
63+ while (low < high) {
64+ while (low < high && lessThan(*low, *end))
65+ ++low;
66+
67+ while (high > low && lessThan(*end, *high))
68+ --high;
69+
70+ if (low < high) {
71+ qSwap(*low, *high);
72+ ++low;
73+ --high;
74+ } else {
75+ break;
76+ }
77+ }
78+
79+ if (lessThan(*low, *end))
80+ ++low;
81+
82+ qSwap(*end, *low);
83+ sortHelper(start, low, t, lessThan);
84+
85+ start = low + 1;
86+ ++end;
87+ goto top;
88+}
89+
90+
91 void ArrayData::sort(ExecutionContext *context, ObjectRef thisObject, const ValueRef comparefn, uint len)
92 {
93 if (!len)
94@@ -765,7 +819,7 @@ void ArrayData::sort(ExecutionContext *context, ObjectRef thisObject, const Valu
95 ArrayElementLessThan lessThan(context, thisObject, comparefn);
96
97 Value *begin = thisObject->arrayData->data;
98- std::sort(begin, begin + len, lessThan);
99+ sortHelper(begin, begin + len, *begin, lessThan);
100
101 #ifdef CHECK_SPARSE_ARRAYS
102 thisObject->initSparseArray();
103diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
104index 51cd699..4b47e55 100644
105--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
106+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
107@@ -135,6 +135,7 @@ private slots:
108 void reentrancy_objectCreation();
109 void jsIncDecNonObjectProperty();
110 void JSONparse();
111+ void arraySort();
112
113 void qRegExpInport_data();
114 void qRegExpInport();
115@@ -2729,6 +2730,24 @@ void tst_QJSEngine::JSONparse()
116 QVERIFY(ret.isObject());
117 }
118
119+void tst_QJSEngine::arraySort()
120+{
121+ // tests that calling Array.sort with a bad sort function doesn't cause issues
122+ // Using std::sort is e.g. not safe when used with a bad sort function and causes
123+ // crashes
124+ QJSEngine eng;
125+ eng.evaluate("function crashMe() {"
126+ " var data = [];"
127+ " for (var i = 0; i < 50; i++) {"
128+ " data[i] = 'whatever';"
129+ " }"
130+ " data.sort(function(a, b) {"
131+ " return -1;"
132+ " });"
133+ "}"
134+ "crashMe();");
135+}
136+
137 static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; }
138
139 void tst_QJSEngine::qRegExpInport_data()
140diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml b/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
141index 5e2892a..b130408 100644
142--- a/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
143+++ b/tests/auto/qml/qqmlecmascript/data/sequenceSort.qml
144@@ -23,7 +23,7 @@ Item {
145 }
146
147 function compareStrings(a, b) {
148- return (a < b) ? 1 : -1;
149+ return (a == b) ? 0 : ((a < b) ? 1 : -1);
150 }
151
152 function compareNumbers(a, b) {
153--
1542.1.3
155
0156
=== modified file 'debian/patches/series'
--- debian/patches/series 2014-09-23 09:59:27 +0000
+++ debian/patches/series 2014-12-08 11:05:28 +0000
@@ -4,3 +4,5 @@
4aarch64.patch4aarch64.patch
5ppc64el.patch5ppc64el.patch
6Support-RFC2822Date-date-format-similar-to-V8.patch6Support-RFC2822Date-date-format-similar-to-V8.patch
7Avoid-race-condition-in-QQmlEngine-on-shutdown.patch
8Fix-crashes-when-calling-Array.sort-with-imperfect-s.patch

Subscribers

People subscribed via source and target branches