|
KiCad PCB EDA Suite
|
#include <navlib_safe_init.h>#include <wx/log.h>#include <atomic>#include <exception>#include <mutex>#include <signal.h>#include <setjmp.h>Go to the source code of this file.
Functions | |
| static std::atomic< bool > | s_driverCrashed (false) |
| static void | navlibSigAbrtHandler (int aSignal) |
| bool | SafeNavlibInit (const std::function< void()> &aInitFunc) |
| Attempt to run the given function, recovering from both C++ exceptions and abort() calls triggered by buggy third-party drivers. | |
| bool | NavlibDriverCrashed () |
| Returns true if a previous SafeNavlibInit call detected a driver crash. | |
Variables | |
| static std::mutex | s_initMutex |
| static sigjmp_buf | s_jumpBuffer |
| static struct sigaction | s_savedSigAbrtAction |
| bool NavlibDriverCrashed | ( | ) |
Returns true if a previous SafeNavlibInit call detected a driver crash.
Once the driver is known to be broken, all future SafeNavlibInit calls return false immediately without attempting initialization.
Definition at line 133 of file navlib_safe_init.cpp.
References s_driverCrashed().
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), NL_3D_VIEWER_PLUGIN::NL_3D_VIEWER_PLUGIN(), NL_FOOTPRINT_PROPERTIES_PLUGIN::NL_FOOTPRINT_PROPERTIES_PLUGIN(), NL_GERBVIEW_PLUGIN::NL_GERBVIEW_PLUGIN(), NL_PCBNEW_PLUGIN::NL_PCBNEW_PLUGIN(), NL_PL_EDITOR_PLUGIN::NL_PL_EDITOR_PLUGIN(), and NL_SCHEMATIC_PLUGIN::NL_SCHEMATIC_PLUGIN().
|
static |
Definition at line 44 of file navlib_safe_init.cpp.
References s_jumpBuffer.
Referenced by SafeNavlibInit().
|
static |
Referenced by NavlibDriverCrashed(), and SafeNavlibInit().
| bool SafeNavlibInit | ( | const std::function< void()> & | aInitFunc | ) |
Attempt to run the given function, recovering from both C++ exceptions and abort() calls triggered by buggy third-party drivers.
On macOS, temporarily installs a SIGABRT handler that uses siglongjmp to recover from abort(). On other platforms, wraps the call in a try/catch.
| aInitFunc | the initialization function to call |
Definition at line 52 of file navlib_safe_init.cpp.
References navlibSigAbrtHandler(), s_driverCrashed(), s_initMutex, s_jumpBuffer, and s_savedSigAbrtAction.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), NL_3D_VIEWER_PLUGIN_IMPL::Connect(), NL_PCBNEW_PLUGIN_IMPL::NL_PCBNEW_PLUGIN_IMPL(), NL_GERBVIEW_PLUGIN_IMPL::SetCanvas(), NL_PL_EDITOR_PLUGIN_IMPL::SetCanvas(), and NL_SCHEMATIC_PLUGIN_IMPL::SetCanvas().
|
static |
Definition at line 40 of file navlib_safe_init.cpp.
Referenced by SafeNavlibInit().
|
static |
Definition at line 41 of file navlib_safe_init.cpp.
Referenced by navlibSigAbrtHandler(), and SafeNavlibInit().
|
static |
Definition at line 42 of file navlib_safe_init.cpp.
Referenced by SafeNavlibInit().