CoreML MLE5ProgramLibrary AOT recompilation hangs/crashes on iOS 26.4 — C++ exception in espresso IR compiler bypasses Swift error handling

Area: CoreML / Machine Learning

Describe the issue:
On iOS 26.4, calling MLModel(contentsOf:configuration:) to load an .mlpackage model hangs indefinitely and eventually kills the app via watchdog. The same model loads and runs inference successfully in under 1
second on iOS 26.3.1.

The hang occurs inside eort_eo_compiler_compile_from_ir_program (espresso) during on-device AOT recompilation triggered by MLE5ProgramLibraryOnDeviceAOTCompilationImpl
createProgramLibraryHandleWithRespecialization:error:. A C++ exception (__cxa_throw) is thrown inside libBNNS.dylib during the exception unwind, which then hangs inside __cxxabiv1::dyn_cast_slow and __class_type_info::search_below_dst.

Swift's try/catch does not catch this — the exception originates in C++ and the process hangs rather than terminating cleanly.

Setting config.computeUnits = .cpuOnly does not resolve the issue. MLE5ProgramLibrary initialises as shared infrastructure regardless of compute units.

Steps to reproduce:

  1. Create an app with an .mlpackage CoreML model using the MLE5/espresso backend
  2. Call MLModel(contentsOf: modelURL, configuration: config) at runtime
  3. Run on a device on iOS 26.3.1 — loads successfully in <1 second
  4. Update device to iOS 26.4 — hangs indefinitely, app killed by watchdog after 60–745 seconds

Expected behaviour:
Model loads successfully, or throws a catchable Swift error on failure.

Actual behaviour:
Process hangs in MLE5ProgramLibrary.lazyInitQueue. App killed by watchdog. No Swift error thrown.

Full stack trace at point of hang:
Thread 1 Queue: com.apple.coreml.MLE5ProgramLibrary.lazyInitQueue (serial)
frame 0: __cxxabiv1::__class_type_info::search_below_dst libc++abi.dylib frame 1: __cxxabiv1::(anonymous namespace)::dyn_cast_slow libc++abi.dylib
frame 2: ___lldb_unnamed_symbol_23ab44dd4 libBNNS.dylib
frame 23: eort_eo_compiler_compile_from_ir_program espresso
frame 24: -[MLE5ProgramLibraryOnDeviceAOTCompilationImpl createProgramLibraryHandleWithRespecialization:error:] CoreML
frame 25: -[MLE5ProgramLibrary _programLibraryHandleWithForceRespecialization:error:] CoreML
frame 26: __44-[MLE5ProgramLibrary prepareAndReturnError:]_block_invoke CoreML
frame 27: _dispatch_client_callout libdispatch.dylib
frame 28: _dispatch_lane_barrier_sync_invoke_and_complete libdispatch.dylib
frame 29: -[MLE5ProgramLibrary prepareAndReturnError:] CoreML
frame 30: -[MLE5Engine initWithContainer:configuration:error:] CoreML
frame 31: +[MLE5Engine loadModelFromCompiledArchive:modelVersionInfo:compilerVersionInfo:configuration:error:] CoreML frame 32: +[MLLoader _loadModelWithClass:fromArchive:modelVersionInfo:compilerVersionInfo:configuration:error:] CoreML
frame 45: +[MLModel modelWithContentsOfURL:configuration:error:] CoreML
frame 46: @nonobjc MLModel.__allocating_init(contentsOf:configuration:) GKPersonalV2
frame 47: MDNA_GaitEncoder_v1_3.__allocating_init(contentsOf:configuration:)
frame 48: MDNA_GaitEncoder_v1_3.__allocating_init(configuration:)
frame 50: GaitModelInference.loadModel()
frame 51: GaitModelInference.init()

iOS version: Reproduced on iOS 26.4. Works correctly on iOS 26.3.1.
Xcode version: 26.2
Device: iPhone (model used in testing)
Model format: .mlpackage

CoreML MLE5ProgramLibrary AOT recompilation hangs/crashes on iOS 26.4 — C&#43;&#43; exception in espresso IR compiler bypasses Swift error handling
 
 
Q