Describe the issue
Onnxruntime C/C++ api causes a heap double free error when using
onnx_api->RegisterExecutionProviderLibrary(onnx_env, "openvino", ORT_TSTR("onnxruntime_providers_openvino.dll"));
To reproduce
- Compile onnxruntime using this command
uv run onnxruntime\tools\ci_build\build.py --config Debug --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --skip_tests --use_dml --use_openvino --cmake_generator Ninja --build_dir "build" --cmake_extra_defines "onnxruntime_ENABLE_TRAINING=OFF" "onnxruntime_ENABLE_TRAINING_APIS=OFF" "onnxruntime_ENABLE_TRAINING_OPS=OFF" "onnxruntime_BUILD_BENCHMARKS=OFF" "OpenVINO_DIR=$pwd/deps/openvino/runtime/cmake"
- For openvino, I have used this OpenVINO release.
- After copying around the
.dll files to the correct directories, this is the minimal reproducible code.
C API example
#include "stdio.h"
#include "stdint.h"
#include "onnxruntime_c_api.h"
#define Assert(x, ...) \
do \
{ \
if (!x) \
{ \
printf(__VA_ARGS__); \
__debugbreak(); \
} \
} while (0)
int main()
{
// Get api table
const OrtApi *onnx_api = OrtGetApiBase()->GetApi(ORT_API_VERSION);
Assert(onnx_api, "Failed to fetch ONNX Runtime API table");
// setup ort env
OrtEnv *onnx_env = NULL;
OrtStatus *status = onnx_api->CreateEnv(ORT_LOGGING_LEVEL_INFO, "Session", &onnx_env);
Assert(!status, "ORT API Error: %s", onnx_api->GetErrorMessage(status));
status = onnx_api->RegisterExecutionProviderLibrary(onnx_env, "openvino", ORT_TSTR("onnxruntime_providers_openvino.dll"));
Assert(!status, "ORT API Error: %s", onnx_api->GetErrorMessage(status));
// cleanup
onnx_api->UnregisterExecutionProviderLibrary(onnx_env, "openvino");
if (onnx_env != NULL)
onnx_api->ReleaseEnv(onnx_env);
}
C++ API example
#include <iostream>
#include "onnxruntime_cxx_api.h"
int main(int argc, char **argv)
{
try
{
auto api = Ort::GetApi();
auto env = Ort::Env(ORT_LOGGING_LEVEL_WARNING);
env.RegisterExecutionProviderLibrary("openvino", L"onnxruntime_providers_openvino.dll");
}
catch (const std::runtime_error &err)
{
std::cerr << err.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
C API
status = onnx_api->RegisterExecutionProviderLibrary(onnx_env, "openvino", ORT_TSTR("onnxruntime_providers_openvino.dll"));
Assert(!status, "ORT API Error: %s", onnx_api->GetErrorMessage(status));
// cleanup
onnx_api->UnregisterExecutionProviderLibrary(onnx_env, "openvino");
C++ API
env.RegisterExecutionProviderLibrary("openvino", L"onnxruntime_providers_openvino.dll");
Urgency
This bug is not letting me incorporate OpenVINO for onnxruntime in my project. I'd say the issue is pretty urgent, even for onnxruntime itself because it can potentially break OpenVINO execution providers in applications that use onnxruntime for AI inference.
Platform
Windows
OS Version
10
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
6c522b4
ONNX Runtime API
C and C++
Architecture
X64
Execution Provider
OpenVINO
Execution Provider Library Version
2026.2.1
Describe the issue
Onnxruntime C/C++ api causes a heap double free error when using
onnx_api->RegisterExecutionProviderLibrary(onnx_env, "openvino", ORT_TSTR("onnxruntime_providers_openvino.dll"));To reproduce
uv run onnxruntime\tools\ci_build\build.py --config Debug --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --skip_tests --use_dml --use_openvino --cmake_generator Ninja --build_dir "build" --cmake_extra_defines "onnxruntime_ENABLE_TRAINING=OFF" "onnxruntime_ENABLE_TRAINING_APIS=OFF" "onnxruntime_ENABLE_TRAINING_OPS=OFF" "onnxruntime_BUILD_BENCHMARKS=OFF" "OpenVINO_DIR=$pwd/deps/openvino/runtime/cmake".dllfiles to the correct directories, this is the minimal reproducible code.C API example
C++ API example
This triggers the breakpoint in debug_alloc.cc:178
And removing these lines fixes the error
C API
C++ API
Urgency
This bug is not letting me incorporate OpenVINO for onnxruntime in my project. I'd say the issue is pretty urgent, even for onnxruntime itself because it can potentially break OpenVINO execution providers in applications that use onnxruntime for AI inference.
Platform
Windows
OS Version
10
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
6c522b4
ONNX Runtime API
C and C++
Architecture
X64
Execution Provider
OpenVINO
Execution Provider Library Version
2026.2.1