Skip to content

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

Closed

Description

@phial3

Describe

env: macOS 15.5 M2 Pro
version: onnxruntime-osx-arm64-1.22.0
error: The project program has been completed, Finally, this error occurred.

this is debug with lldb

libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
Process 67904 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x0000000199bd9388 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x199bd9388 <+8>:  b.lo   0x199bd93a8    ; <+40>
    0x199bd938c <+12>: pacibsp 
    0x199bd9390 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x199bd9394 <+20>: mov    x29, sp
Target 0: (yolo) stopped.
(lldb) bt
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x0000000199bd9388 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x0000000199c1288c libsystem_pthread.dylib`pthread_kill + 296
    frame #2: 0x0000000199b1bc60 libsystem_c.dylib`abort + 124
    frame #3: 0x0000000199bc839c libc++abi.dylib`abort_message + 132
    frame #4: 0x0000000199bb6cf0 libc++abi.dylib`demangling_terminate_handler() + 316
    frame #5: 0x000000019983cde4 libobjc.A.dylib`_objc_terminate() + 172
    frame #6: 0x0000000199bc76b0 libc++abi.dylib`std::__terminate(void (*)()) + 16
    frame #7: 0x0000000199bc7654 libc++abi.dylib`std::terminate() + 108
    frame #8: 0x000000010f302f34 libonnxruntime.1.22.0.dylib`__clang_call_terminate + 12
    frame #9: 0x000000010e68b054 libonnxruntime.1.22.0.dylib`std::__1::unique_ptr<OrtEnv, std::__1::default_delete<OrtEnv>>::~unique_ptr[abi:ue170006]() + 84
    frame #10: 0x0000000199aca944 libsystem_c.dylib`__cxa_finalize_ranges + 480
    frame #11: 0x0000000199aca704 libsystem_c.dylib`exit + 44
    frame #12: 0x0000000199c1cdc8 libdyld.dylib`dyld4::LibSystemHelpers::exit(int) const + 20
    frame #13: 0x0000000199872cac dyld`dyld4::LibSystemHelpersWrapper::exit(int) const + 172
    frame #14: 0x0000000199872bc8 dyld`start + 6124
(lldb) 

Activity

  1. decahedron1 commented on Jun 17, 2025

    @decahedron1
    Member

    This was fixed in pyke binaries with this patch: https://github.com/pykeio/ort-artifacts/blob/77ec493e3495901a361469951ab992181e52fd05/src/patches/all/0003-leak-logger-mutex.patch

    You could build ONNX Runtime from source with that patch applied, or just ignore the error. I'd recommend the former.

  2. utdemir commented on Jun 23, 2025

    @utdemir

    Hey @decahedron1 - any chance you could submit the patch upstream? We're using ort using the precompiled objects from the microsoft/onnxruntime repo (because they support a newer glibc version) - and might be hitting this issue.

    I'd offer to submit the patch myself but unfortunately not familiar with the internals. So apologies for adding to the maintenance burden.

  3. decahedron1 commented on Jun 23, 2025

    @decahedron1
    Member
  4. snnn commented on Jun 25, 2025

    @snnn

    Please try to not declare OrtEnv as a global var. Even though @decahedron1 's PR fixed the crash, there might other problems. You may either leak the OrtEnv* pointer(if you use the latest onnx runtime main instead of the 1.22 release), or delete it before main is returned. Because we want to make sure that OrtEnv's destructor won't be called after Ort itself was already half destroyed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions