Skip to content

[Build] Xcode unit tests fail with libc++abi: terminating due to uncaught exception of type onnxruntime::OnnxRuntimeException: #23259

Open
@iOSDevD

Description

Describe the issue

When the unit tests are executed it fails with below exception.

libc++abi: terminating due to uncaught exception of type onnxruntime::OnnxRuntimeException: core/session/ort_env.cc:90 static void OrtEnv::Release(OrtEnv *) env_ptr == p_instance_.get() was false.

Urgency

No response

Target platform

iOS

Build script

  • Open Xcode
  • Create a sample unit tests
  • Run the unit tests
  • After the test completes it will crash with the OnnxRuntimeException

If we simply run the code on simulator all works fine, but fails only with unit tests.

Error / output

libc++abi: terminating due to uncaught exception of type onnxruntime::OnnxRuntimeException: core/session/ort_env.cc:90 static void OrtEnv::Release(OrtEnv *) env_ptr == p_instance_.get() was false.

TestFramework is the name of the XCFramework.

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x0000000102f3d008 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x00000001030a3408 libsystem_pthread.dylib`pthread_kill + 256
    frame #2: 0x000000018016c4ec libsystem_c.dylib`abort + 104
    frame #3: 0x00000001802ac100 libc++abi.dylib`abort_message + 128
    frame #4: 0x000000018029bae8 libc++abi.dylib`demangling_terminate_handler() + 272
    frame #5: 0x000000018006b8bc libobjc.A.dylib`_objc_terminate() + 140
    frame #6: 0x00000001038950fc XCTestCore`_XCTTerminateHandler() + 96
    frame #7: 0x00000001802ab4d8 libc++abi.dylib`std::__terminate(void (*)()) + 12
    frame #8: 0x00000001802ab488 libc++abi.dylib`std::terminate() + 52
    frame #9: 0x00000001280024c8 TestFramework`__clang_call_terminate + 12
    frame #10: 0x00000001280f650c TestFramework`OrtApis::ReleaseEnv(OrtEnv*) + 24
    frame #11: 0x0000000128013af8 TestFramework`Ort::Env::~Env() + 40
    frame #12: 0x000000018014d0b8 libsystem_c.dylib`__cxa_finalize_ranges + 424
    frame #13: 0x000000018014d44c libsystem_c.dylib`exit + 28
    frame #14: 0x00000001038bffa4 XCTestCore`_XCTestMain + 136
    frame #15: 0x0000000102e20d28 xctest`static xctesttool.xctest.main() -> () + 428
    frame #16: 0x0000000102e20e20 xctest`static xctesttool.xctest.$main() -> () + 12
    frame #17: 0x0000000102e20e34 xctest`main + 12
    frame #18: 0x0000000102fd5410 dyld_sim`start_sim + 20
    frame #19: 0x00000001030de274 dyld`start + 2840

Visual Studio Version

No response

GCC / Compiler Version

No response

OnnxRuntime Version

1.13.X

Metadata

Assignees

No one assigned

    Labels

    buildbuild issues; typically submitted using templateplatform:mobileissues related to ONNX Runtime mobile; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions