Merge pull request #15970 from akemimadoka:master

* Fix android armv7 c++_static init crash

* core: move initialization of 'ios_base::Init' for Android
pull/14666/head
Natsu 6 years ago committed by Alexander Alekhin
parent ca28274895
commit 54e6f5c237
  1. 2
      modules/core/src/logger.cpp
  2. 15
      modules/core/src/system.cpp

@ -21,6 +21,8 @@ namespace logging {
static LogLevel parseLogLevelConfiguration()
{
(void)getInitializationMutex(); // ensure initialization of global objects
static cv::String param_log_level = utils::getConfigurationParameterString("OPENCV_LOG_LEVEL",
#if defined NDEBUG
"WARNING"

@ -55,11 +55,26 @@
namespace cv {
static void _initSystem()
{
#ifdef __ANDROID__
// https://github.com/opencv/opencv/issues/14906
// "ios_base::Init" object is not a part of Android's "iostream" header (in case of clang toolchain, NDK 20).
// Ref1: https://en.cppreference.com/w/cpp/io/ios_base/Init
// The header <iostream> behaves as if it defines (directly or indirectly) an instance of std::ios_base::Init with static storage duration
// Ref2: https://github.com/gcc-mirror/gcc/blob/gcc-8-branch/libstdc%2B%2B-v3/include/std/iostream#L73-L74
static std::ios_base::Init s_iostream_initializer;
#endif
}
static Mutex* __initialization_mutex = NULL;
Mutex& getInitializationMutex()
{
if (__initialization_mutex == NULL)
{
(void)_initSystem();
__initialization_mutex = new Mutex();
}
return *__initialization_mutex;
}
// force initialization (single-threaded environment)

Loading…
Cancel
Save