cmake libc++abi.dylib:终止时出现std::__1::system_error类型的未捕获异常:互斥锁失败:参数无效

g0czyy6m  于 7个月前  发布在  其他
关注(0)|答案(3)|浏览(123)

我有一些线程池的代码,已经在我的Ubuntu机器上工作了很长一段时间。这个项目是一个CMake项目,我相信它使用了最新版本的g++作为编译器。
我刚试着在Mac上运行代码,CMake尝试使用AppleClang 12.0.0.12000032,我被击中了

libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument

字符串
AppleClang缺少std::shared_mutexstd::mutex吗?这些都是c17功能。我需要做些什么才能在这台Mac上启用c17吗?我确实提到了在我的CMakeLists.txt文件中需要它。
以下是完整的构建输出:

(base) clare.obrien.brown@Clares-Air build % cmake ..
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/clare.obrien.brown/ssme/build
(base) clare.obrien.brown@Clares-Air build % make
Scanning dependencies of target ssme_test
[ 16%] Building CXX object test/CMakeFiles/ssme_test.dir/test-main.cpp.o
[ 33%] Building CXX object test/CMakeFiles/ssme_test.dir/test_ada_pmmh_mvn.cpp.o
[ 50%] Building CXX object test/CMakeFiles/ssme_test.dir/test_parameters.cpp.o
In file included from /Users/clare.obrien.brown/ssme/test/test_parameters.cpp:5:
/Users/clare.obrien.brown/ssme/include/ssme/parameters.h:333:58: warning: unused parameter 'trans_p' [-Wunused-parameter]
float_t null_trans<float_t>::log_jacobian(const float_t& trans_p)
                                                         ^
1 warning generated.
[ 66%] Building CXX object test/CMakeFiles/ssme_test.dir/test_thread_pool.cpp.o
/Users/clare.obrien.brown/ssme/test/test_thread_pool.cpp:13:46: warning: unused parameter 'obs_data' [-Wunused-parameter]
    static double d(param_t nums, obs_data_t obs_data) {
                                             ^
/Users/clare.obrien.brown/ssme/test/test_thread_pool.cpp:54:45: warning: unused parameter 'od' [-Wunused-parameter]
                [](param_t nums, obs_data_t od) -> double{
                                            ^
/Users/clare.obrien.brown/ssme/test/test_thread_pool.cpp:82:40: warning: unused parameter 'ydata' [-Wunused-parameter]
    double d(param_t theta, obs_data_t ydata) {
                                       ^
3 warnings generated.
[ 83%] Building CXX object test/CMakeFiles/ssme_test.dir/test_utils.cpp.o
[100%] Linking CXX executable ssme_test
[100%] Built target ssme_test
(base) clare.obrien.brown@Clares-Air build % cd ../test 
(base) clare.obrien.brown@Clares-Air test % ../build/test/ssme_test 
libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
zsh: abort      ../build/test/ssme_test

kxkpmulp

kxkpmulp1#

下面是抛出异常的位置:https://github.com/llvm/llvm-project/blob/main/libcxx/src/mutex.cpp#L35
这通常发生在.lock()在尚未构造或已被析构的mutex上被调用时。当在main()之前访问具有静态存储持续时间的互斥锁时,可能会发生这种情况。或者在main()返回之后。您需要检查启动或关闭逻辑,以确保mutex的生存期超过客户试图使用它。
/Applications/Utilities/Console.app可以在抛出未捕获异常时为您提供应用程序的堆栈跟踪。这可能有助于您的调试工作。使用-g编译可以为堆栈跟踪提供更好的调试信息。

btxsgosb

btxsgosb2#

当我的手机连接到Xcode时,我在点击一些按钮后出现了这个崩溃错误。从电脑上拔下手机后,按下相同的按钮并没有导致任何崩溃。

goqiplq2

goqiplq23#

我有这个错误是由于一个重复的导入-我消除了一个,它开始工作。

相关问题