qt5base-lts/tests/auto/corelib/kernel
Marc Mutz f5291bf8b4 Fix UB in tst_QObject::noDeclarativeParentChangedOnDestruction()
If QObjectPrivate::declarativeData is set, it is
in various places in Qt expected to point to a
QAbstractDeclarativeDataImpl, from which ownedByQml1
is unconditionally read.

In noDeclarativeParentChangedOnDestruction(), the
declarativeData pointer is, however, set to a local
QAbstractDeclarativeData instance, which, being an
empty class, has size 1 and alignment 1.

Depending on the compiler's idea of bit field order,
this code either read uninitialized data from the
dummy object, or else some random stack memory outside
any (valid) object.

What caught UBSan's attention, though, was the
difference in alignment between the two classes:

  src/corelib/kernel/qobject.cpp:917:9: runtime error: member access within misaligned address 0x7fffc9cf706f for type 'struct QAbstractDeclarativeDataImpl', which requires 4 byte alignment

Fix by providing a properly initialized object of the
correct type.

Change-Id: Iae83a949ee5a7bc98df13e35ea614c063085fa13
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-01-07 13:00:28 +00:00
..
qcoreapplication Fix tst_QGuiApplication for embedded platforms using eglfs QPA 2015-09-10 06:29:11 +00:00
qeventdispatcher Update copyright headers 2015-02-11 06:49:51 +00:00
qeventloop fix usage of wince scope 2015-06-05 10:29:10 +00:00
qmath Update copyright headers 2015-02-11 06:49:51 +00:00
qmetaenum Fix QtPrivate::IsQEnumHelper<void> 2015-05-17 09:13:18 +00:00
qmetamethod Update copyright headers 2015-02-11 06:49:51 +00:00
qmetaobject Output registered enums in qDebug operator for QFlags. 2015-02-26 12:16:51 +00:00
qmetaobjectbuilder Update copyright headers 2015-02-11 06:49:51 +00:00
qmetaproperty Update copyright headers 2015-02-11 06:49:51 +00:00
qmetatype Fix UB in tst_QMetaType 2016-01-06 22:07:09 +00:00
qmimedata Add support to set text/uri-list mimedata via setData() 2015-04-28 12:46:35 +00:00
qobject Fix UB in tst_QObject::noDeclarativeParentChangedOnDestruction() 2016-01-07 13:00:28 +00:00
qpointer Update copyright headers 2015-02-11 06:49:51 +00:00
qsharedmemory Skip instead of entirely excluding tests with disabled features 2015-03-16 09:34:15 +00:00
qsignalblocker Update copyright headers 2015-02-11 06:49:51 +00:00
qsignalmapper Update copyright headers 2015-02-11 06:49:51 +00:00
qsocketnotifier Fix the spurious socket notifications under Windows 2015-09-10 12:51:02 +00:00
qsystemsemaphore Skip instead of entirely excluding tests with disabled features 2015-03-16 09:34:15 +00:00
qtimer Fix the remainingTime() result after the first activation of a QTimer 2015-07-08 03:20:29 +00:00
qtranslator Update copyright headers 2015-02-11 06:49:51 +00:00
qvariant Fix building tests on QNX 2015-03-09 11:23:24 +00:00
qwineventnotifier Update copyright headers 2015-02-11 06:49:51 +00:00
kernel.pro iOS: Skip tests that don't make sense or don't work on the platform 2015-03-16 14:25:27 +00:00