fix(onnx): Use patched version of onnxruntime
Some checks failed
build / checks-matrix (push) Successful in 19m21s
build / codecov (push) Failing after 19m26s
docs / docs (push) Failing after 28m47s
build / checks-build (push) Has been cancelled

This commit is contained in:
uttarayan21
2025-08-19 15:28:38 +05:30
parent 3d56db687c
commit 33798467ba
2 changed files with 47 additions and 2 deletions

View File

@@ -86,6 +86,9 @@
"-Donnxruntime_BUILD_STATIC_LIB=ON"
];
});
patchedOnnxruntime = pkgs.onnxruntime.overrideAttrs (old: {
patches = [./patches/ort_env_global_mutex.patch];
});
src = let
filterBySuffix = path: exts: lib.any (ext: lib.hasSuffix ext path) exts;
sourceFilters = path: type:
@@ -111,8 +114,8 @@
stdenv = p: p.clangStdenv;
doCheck = false;
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
ORT_LIB_LOCATION = "${pkgs.onnxruntime}";
ORT_ENV_SYSTEM_LIB_LOCATION = "${pkgs.onnxruntime}/lib";
ORT_LIB_LOCATION = "${patchedOnnxruntime}";
ORT_ENV_SYSTEM_LIB_LOCATION = "${patchedOnnxruntime}/lib";
ORT_ENV_PREFER_DYNAMIC_LINK = true;
nativeBuildInputs = with pkgs; [
cmake

View File

@@ -0,0 +1,42 @@
From 83e1dbf52b7695a2966795e0350aaa385d1ba8c8 Mon Sep 17 00:00:00 2001
From: "Carson M." <carson@pyke.io>
Date: Sun, 22 Jun 2025 23:53:20 -0500
Subject: [PATCH] Leak logger mutex
---
onnxruntime/core/common/logging/logging.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/onnxruntime/core/common/logging/logging.cc b/onnxruntime/core/common/logging/logging.cc
index a79e7300cffce..07578fc72ca99 100644
--- a/onnxruntime/core/common/logging/logging.cc
+++ b/onnxruntime/core/common/logging/logging.cc
@@ -64,8 +64,8 @@ LoggingManager* LoggingManager::GetDefaultInstance() {
#pragma warning(disable : 26426)
#endif
-static std::mutex& DefaultLoggerMutex() noexcept {
- static std::mutex mutex;
+static std::mutex* DefaultLoggerMutex() noexcept {
+ static std::mutex* mutex = new std::mutex();
return mutex;
}
@@ -107,7 +107,7 @@ LoggingManager::LoggingManager(std::unique_ptr<ISink> sink, Severity default_min
// lock mutex to create instance, and enable logging
// this matches the mutex usage in Shutdown
- std::lock_guard<std::mutex> guard(DefaultLoggerMutex());
+ std::lock_guard<std::mutex> guard(*DefaultLoggerMutex());
if (DefaultLoggerManagerInstance().load() != nullptr) {
ORT_THROW("Only one instance of LoggingManager created with InstanceType::Default can exist at any point in time.");
@@ -127,7 +127,7 @@ LoggingManager::LoggingManager(std::unique_ptr<ISink> sink, Severity default_min
LoggingManager::~LoggingManager() {
if (owns_default_logger_) {
// lock mutex to reset DefaultLoggerManagerInstance() and free default logger from this instance.
- std::lock_guard<std::mutex> guard(DefaultLoggerMutex());
+ std::lock_guard<std::mutex> guard(*DefaultLoggerMutex());
#if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
DefaultLoggerManagerInstance().store(nullptr, std::memory_order_release);
#else