Mantid
Loading...
Searching...
No Matches
Segfault.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9namespace Mantid::Algorithms {
10
11// Register the algorithm into the AlgorithmFactory
12DECLARE_ALGORITHM(Segfault)
13
14//----------------------------------------------------------------------------------------------
15
16
17const std::string Segfault::name() const { return "Segfault"; }
18
20int Segfault::version() const { return 1; }
21
23const std::string Segfault::category() const { return "Utility\\Development"; }
24
26const std::string Segfault::summary() const { return "WARNING: THIS CRASHES MANTID"; }
27
28//----------------------------------------------------------------------------------------------
31void Segfault::init() { declareProperty("DryRun", true, "Just log to the error channel but don't crash mantid"); }
32
33//----------------------------------------------------------------------------------------------
37 bool dryrun = getProperty("DryRun");
38 g_log.error("Crashing mantid now");
39
40 if (!dryrun) {
41 // NULL pointer dereference
42 int *ptr = nullptr;
43 // cppcheck-suppress nullPointer
44 *ptr = 1;
45 }
46}
47
48} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
Kernel::Logger & g_log
Definition: Algorithm.h:451
Segfault : TODO: DESCRIPTION.
Definition: Segfault.h:17
void init() override
Initialize the algorithm's properties.
Definition: Segfault.cpp:31
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
Definition: Segfault.cpp:26
void exec() override
Execute the algorithm.
Definition: Segfault.cpp:36
const std::string category() const override
Algorithm's category for identification.
Definition: Segfault.cpp:23
int version() const override
Algorithm's version for identification.
Definition: Segfault.cpp:20
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
STL namespace.