fix: CoreML EP crash when loading model with external data file#28043
Open
Scottcjn wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: CoreML EP crash when loading model with external data file#28043Scottcjn wants to merge 1 commit intomicrosoft:mainfrom
Scottcjn wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…path TensorProtoWithExternalDataToTensorProto() passes model_path (full file path like "/path/to/model.onnx") directly to ReadExternalDataForTensor(), which expects a directory. This causes GetExternalDataInfo() to construct invalid paths like "/path/to/model.onnx/model.onnx_data" instead of "/path/to/model.onnx_data". The bug only affects the CoreML EP because it's the only production caller that passes a non-empty model_path. CPU EP uses UnpackInitializerData() which correctly calls model_path.parent_path(). Fix: use model_path.parent_path(), matching the established pattern at line ~2572. Fixes microsoft#28005 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #28005
CoreML EP crashes with SIGBUS when loading models that use external data files (.onnx_data). CPU EP works fine which is what tipped me off that it was provider-specific.
The bug is in TensorProtoWithExternalDataToTensorProto() -- it passes model_path straight to ReadExternalDataForTensor() but model_path is the full file path like /path/to/model.onnx not the directory. So GetExternalDataInfo() builds a garbage path like /path/to/model.onnx/model.onnx_data.
Fix is model_path.parent_path() instead. Same thing UnpackInitializerData() already does at line ~2572. Only affects CoreML EP since thats the only caller passing a non-empty path here.