blob: 117bdbc306e2061068bb3d6945587c5661616853 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QQmlEngine>
#include <QJSEngine>
#include "qmlcrash.h"
#include <signal.h>
static QObject *qmlCrash_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(scriptEngine)
return new QmlCrash(engine);
}
void QmlCrashPlugin::registerTypes(const char *uri)
{
qmlRegisterSingletonType<QmlCrash>(uri, 2, 0, "QmlCrash", qmlCrash_provider);
}
static void abortWithVeryLongSymbolNameOnTheStack800CharactersLong_CallMeIshmaelSomeYearsAgoNeverMindHowLongPreciselyHavingLittleOrNoMoneyInMyPurseAndNothingParticularToInterestMeOnShoreIThoughIWouldSailAboutALittlAndSeeTheWateryPartOfTheWorldItIsAWayIHaveOfDrivingOffTheSpleenAndRegulatingTheCirculationWhenenverIFindMyselfGrowingGrimAboutTheMouthWheneverItIsADampDrizzlyNovemberInMySoulWheneverIFindMyselfInvoluntarilyPausingBeforeCoffinWarehousesAndBringingUpTheRearOfEveryFuneralIMeetAndEspeciallyWheneverMyHyposGetSuchAnUpperHandOfMeThatItRequiresAStrongMoralPrincipleToPreventMeFromDeliberatelySteppingIntoTheStreetAndMethodicallyKnockingPeoplesHatsOffThenIAccountItHighTimeToGetToSeaAsSoonAsICanThisIsMySubstituteForPistolAndBallWithAPhilosophicalFlourishCatoThrowsHimselfUponHisSwordIQuietlyTakeToTheShip()
{
::abort();
}
void QmlCrash::accessIllegalMemory() const
{
*(int*)1 = 42;
}
void QmlCrash::accessIllegalMemoryInThread()
{
QmlCrashThread *t = new QmlCrashThread(this);
t->start();
}
void QmlCrash::forceStackOverflow() const
{
static constexpr int len = 100000;
volatile char buf[len];
buf[len-1] = 42;
if (buf[len-1] == 42)
forceStackOverflow();
}
void QmlCrash::divideByZero() const
{
int d = 0;
volatile int x = 42 / d;
Q_UNUSED(x)
}
void QmlCrash::abort() const
{
abortWithVeryLongSymbolNameOnTheStack800CharactersLong_CallMeIshmaelSomeYearsAgoNeverMindHowLongPreciselyHavingLittleOrNoMoneyInMyPurseAndNothingParticularToInterestMeOnShoreIThoughIWouldSailAboutALittlAndSeeTheWateryPartOfTheWorldItIsAWayIHaveOfDrivingOffTheSpleenAndRegulatingTheCirculationWhenenverIFindMyselfGrowingGrimAboutTheMouthWheneverItIsADampDrizzlyNovemberInMySoulWheneverIFindMyselfInvoluntarilyPausingBeforeCoffinWarehousesAndBringingUpTheRearOfEveryFuneralIMeetAndEspeciallyWheneverMyHyposGetSuchAnUpperHandOfMeThatItRequiresAStrongMoralPrincipleToPreventMeFromDeliberatelySteppingIntoTheStreetAndMethodicallyKnockingPeoplesHatsOffThenIAccountItHighTimeToGetToSeaAsSoonAsICanThisIsMySubstituteForPistolAndBallWithAPhilosophicalFlourishCatoThrowsHimselfUponHisSwordIQuietlyTakeToTheShip();
}
void QmlCrash::raise(int sig) const
{
::raise(sig);
}
void QmlCrash::throwUnhandledException() const
{
throw 42;
}
void QmlCrash::exitGracefully() const
{
exit(5);
}
QmlCrashThread::QmlCrashThread(QmlCrash *parent)
: QThread(parent)
, m_qmlCrash(parent)
{ }
void QmlCrashThread::run()
{
m_qmlCrash->accessIllegalMemory();
}
#include "moc_qmlcrash.cpp"
|