-
Notifications
You must be signed in to change notification settings - Fork 122
/
Segfault.cpp
50 lines (39 loc) · 1.77 KB
/
Segfault.cpp
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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAlgorithms/Segfault.h"
namespace Mantid {
namespace Algorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(Segfault)
//----------------------------------------------------------------------------------------------
/// Algorithms name for identification. @see Algorithm::name
const std::string Segfault::name() const { return "Segfault"; }
/// Algorithm's version for identification. @see Algorithm::version
int Segfault::version() const { return 1; }
/// Algorithm's category for identification. @see Algorithm::category
const std::string Segfault::category() const { return "Utility\\Development"; }
/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const std::string Segfault::summary() const { return "WARNING: THIS CRASHES MANTID"; }
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void Segfault::init() { declareProperty("DryRun", true, "Just log to the error channel but don't crash mantid"); }
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void Segfault::exec() {
bool dryrun = getProperty("DryRun");
g_log.error("Crashing mantid now");
if (!dryrun) {
// NULL pointer dereference
int *ptr = nullptr;
// cppcheck-suppress nullPointer
*ptr = 1;
}
}
} // namespace Algorithms
} // namespace Mantid