apache / arrow

Apache Arrow is a multi-language toolbox for accelerated data interchange and in-memory processing
https://arrow.apache.org/
Apache License 2.0
14.27k stars 3.47k forks source link

[Python] mutex lock failed: Invalid argument when importing after tink (M1, macOS 14.2.1) #40088

Open reeseann opened 7 months ago

reeseann commented 7 months ago

Describe the bug, including details regarding any error messages, version, and platform.

import tink
import pyarrow

Results in:

libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument

Reversing import order results in the process hanging with:

[mutex.cc : 453] RAW: Lock blocking 0x156747c38   @

Same error message as #15189. Just in case similar root cause, OpenSSL version Python is built with is OpenSSL 3.2.0 23 Nov 2023.

Component(s)

Python

pitrou commented 7 months ago

Can you perhaps obtain a backtrace using lldb?

reeseann commented 7 months ago
0.  Program arguments: /Library/Developer/CommandLineTools/usr/bin/lldb /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  lldb                     0x000000010414f7dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  lldb                     0x000000010414ed38 llvm::sys::RunSignalHandlers() + 112
2  lldb                     0x000000010414fe14 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018180da24 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001817ddcc0 pthread_kill + 288
5  libsystem_c.dylib        0x00000001816e9a40 abort + 180
6  libc++abi.dylib          0x0000000181795070 __cxxabiv1::__aligned_malloc_with_fallback(unsigned long) + 0
7  libc++abi.dylib          0x0000000181785110 demangling_terminate_handler() + 320
8  libobjc.A.dylib          0x000000018142b99c _objc_terminate() + 160
9  libc++abi.dylib          0x0000000181794434 std::__terminate(void (*)()) + 16
10 libc++abi.dylib          0x0000000181797520 __cxa_get_exception_ptr + 0
11 libc++abi.dylib          0x0000000181797464 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 0
12 libc++.1.dylib           0x00000001817136b8 std::__1::__throw_system_error(int, char const*) + 100
13 libc++.1.dylib           0x0000000181708318 std::__1::mutex::try_lock() + 0
14 libarrow.1500.dylib      0x0000000110d6a330 google::protobuf::internal::OnShutdownRun(void (*)(void const*), void const*) + 72
15 libarrow.1500.dylib      0x0000000110d61880 google::protobuf::internal::InitProtobufDefaultsSlow() + 84
16 libarrow.1500.dylib      0x0000000110dfaca8 google::protobuf::(anonymous namespace)::AddDescriptors(google::protobuf::internal::DescriptorTable const*) + 128
17 libarrow.1500.dylib      0x0000000110dfacec google::protobuf::internal::AddDescriptorsRunner::AddDescriptorsRunner(google::protobuf::internal::DescriptorTable const*) + 24
18 dyld                     0x0000000181479a24 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const::$_0::operator()() const + 168
19 dyld                     0x00000001814bf0f4 invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 172
20 dyld                     0x00000001814b2668 invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 496
21 dyld                     0x00000001814592fc dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 300
22 dyld                     0x00000001814b16a0 dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 192
23 dyld                     0x00000001814b4188 dyld3::MachOFile::forEachInitializerPointerSection(Diagnostics&, void (unsigned int, unsigned int, bool&) block_pointer) const + 160
24 dyld                     0x00000001814bede8 dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 432
25 dyld                     0x0000000181475b38 dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 524
26 dyld                     0x000000018147bf70 dyld4::JustInTimeLoader::runInitializers(dyld4::RuntimeState&) const + 36
27 dyld                     0x0000000181475f24 dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 220
28 dyld                     0x0000000181475f00 dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 184
29 dyld                     0x0000000181475f00 dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 184
30 dyld                     0x0000000181475f00 dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 184
31 dyld                     0x0000000181475f00 dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 184
32 dyld                     0x0000000181479ab0 dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const::$_1::operator()() const + 112
33 dyld                     0x00000001814760f0 dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const + 380
34 dyld                     0x00000001814947ac dyld4::APIs::dlopen_from(char const*, int, void*) + 1576
35 Python3                  0x0000000104ccedf4 _Py_GetLocaleconvNumeric + 756
36 Python3                  0x0000000104c9f66c PyImport_AppendInittab + 5100
37 Python3                  0x0000000104c9ee08 PyImport_AppendInittab + 2952
38 Python3                  0x0000000104beb188 PyCMethod_New + 764
39 Python3                  0x0000000104c77e50 _PyEval_EvalFrameDefault + 23428
40 Python3                  0x0000000104c7b7ec _PyEval_EvalFrameDefault + 38176
41 Python3                  0x0000000104ba8f10 _PyFunction_Vectorcall + 236
42 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
43 Python3                  0x0000000104c77b78 _PyEval_EvalFrameDefault + 22700
44 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
45 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
46 Python3                  0x0000000104c77b54 _PyEval_EvalFrameDefault + 22664
47 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
48 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
49 Python3                  0x0000000104c77bf4 _PyEval_EvalFrameDefault + 22824
50 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
51 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
52 Python3                  0x0000000104c77bf4 _PyEval_EvalFrameDefault + 22824
53 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
54 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
55 Python3                  0x0000000104c77bf4 _PyEval_EvalFrameDefault + 22824
56 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
57 Python3                  0x0000000104baa0cc PyObject_CallMethodObjArgs + 492
58 Python3                  0x0000000104baa258 _PyObject_CallMethodIdObjArgs + 112
59 Python3                  0x0000000104c9daf4 PyImport_ImportModuleLevelObject + 1284
60 Python3                  0x0000000104c76888 _PyEval_EvalFrameDefault + 17852
61 Python3                  0x0000000104c7b7ec _PyEval_EvalFrameDefault + 38176
62 Python3                  0x0000000104c72204 PyEval_EvalCode + 80
63 Python3                  0x0000000104c6eb5c _PyAST_ExprAsUnicode + 19156
64 Python3                  0x0000000104beb188 PyCMethod_New + 764
65 Python3                  0x0000000104c77e50 _PyEval_EvalFrameDefault + 23428
66 Python3                  0x0000000104c7b7ec _PyEval_EvalFrameDefault + 38176
67 Python3                  0x0000000104ba8f10 _PyFunction_Vectorcall + 236
68 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
69 Python3                  0x0000000104c77b78 _PyEval_EvalFrameDefault + 22700
70 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
71 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
72 Python3                  0x0000000104c77b54 _PyEval_EvalFrameDefault + 22664
73 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
74 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
75 Python3                  0x0000000104c77bf4 _PyEval_EvalFrameDefault + 22824
76 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
77 Python3                  0x0000000104c7aa38 _PyEval_EvalFrameDefault + 34668
78 Python3                  0x0000000104c77bf4 _PyEval_EvalFrameDefault + 22824
79 Python3                  0x0000000104ba8fc8 _PyFunction_Vectorcall + 420
80 Python3                  0x0000000104baa0cc PyObject_CallMethodObjArgs + 492
81 Python3                  0x0000000104baa258 _PyObject_CallMethodIdObjArgs + 112
82 Python3                  0x0000000104c9daf4 PyImport_ImportModuleLevelObject + 1284
83 Python3                  0x0000000104c76888 _PyEval_EvalFrameDefault + 17852
84 Python3                  0x0000000104c7b7ec _PyEval_EvalFrameDefault + 38176
85 Python3                  0x0000000104c72204 PyEval_EvalCode + 80
86 Python3                  0x0000000104cb62f0 PyParser_ASTFromStringObject + 500
87 Python3                  0x0000000104cb4eb4 PyRun_StringFlags + 152
88 LLDB                     0x0000000116b8f3f4 lldb_private::python::runStringMultiLine(llvm::Twine const&, lldb_private::python::PythonDictionary const&, lldb_private::python::PythonDictionary const&) + 148
89 LLDB                     0x0000000116b9503c lldb_private::ScriptInterpreterPythonImpl::ExecuteMultipleLines(char const*, lldb_private::ExecuteScriptOptions const&) + 884
90 LLDB                     0x0000000116b9a5c8 lldb_private::ScriptInterpreterPythonImpl::LoadScriptingModule(char const*, lldb_private::LoadScriptOptions const&, lldb_private::Status&, std::__1::shared_ptr<lldb_private::StructuredData::Object>*, lldb_private::FileSpec) + 1924
91 LLDB                     0x0000000116d9342c CommandObjectCommandsScriptImport::DoExecute(lldb_private::Args&, lldb_private::CommandReturnObject&) + 328
92 LLDB                     0x00000001167a5ad0 lldb_private::CommandObjectParsed::Execute(char const*, lldb_private::CommandReturnObject&) + 656
93 LLDB                     0x000000011679c75c lldb_private::CommandInterpreter::HandleCommand(char const*, lldb_private::LazyBool, lldb_private::CommandReturnObject&, bool) + 2024
94 LLDB                     0x000000011679ff9c lldb_private::CommandInterpreter::IOHandlerInputComplete(lldb_private::IOHandler&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>&) + 828
95 LLDB                     0x00000001166d77c8 lldb_private::IOHandlerEditline::Run() + 304
96 LLDB                     0x00000001166bc0c4 lldb_private::Debugger::RunIOHandlers() + 140
97 LLDB                     0x00000001167a1178 lldb_private::CommandInterpreter::RunCommandInterpreter(lldb_private::CommandInterpreterRunOptions&) + 196
98 LLDB                     0x000000011651d798 lldb::SBDebugger::RunCommandInterpreter(bool, bool) + 124
99 lldb                     0x00000001041402b8 Driver::MainLoop() + 2712
100 lldb                     0x0000000104140d14 main + 2036
101 dyld                     0x000000018145d0e0 start + 2360
kou commented 7 months ago

It seems that this is happen at https://github.com/protocolbuffers/protobuf/blob/976a6eb6a4f462c6bb0b2a87fcd95f0aeb17eedb/src/google/protobuf/message_lite.cc#L726 .

Is tink statically linked with its bundled Protobuf? (pyarrow does.) If tink is also linked with its bundled Protobuf, they may be conflicted.