fix(onnx): Use patched version of onnxruntime
This commit is contained in:
@@ -86,6 +86,9 @@
|
|||||||
"-Donnxruntime_BUILD_STATIC_LIB=ON"
|
"-Donnxruntime_BUILD_STATIC_LIB=ON"
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
patchedOnnxruntime = pkgs.onnxruntime.overrideAttrs (old: {
|
||||||
|
patches = [./patches/ort_env_global_mutex.patch];
|
||||||
|
});
|
||||||
src = let
|
src = let
|
||||||
filterBySuffix = path: exts: lib.any (ext: lib.hasSuffix ext path) exts;
|
filterBySuffix = path: exts: lib.any (ext: lib.hasSuffix ext path) exts;
|
||||||
sourceFilters = path: type:
|
sourceFilters = path: type:
|
||||||
@@ -111,8 +114,8 @@
|
|||||||
stdenv = p: p.clangStdenv;
|
stdenv = p: p.clangStdenv;
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||||
ORT_LIB_LOCATION = "${pkgs.onnxruntime}";
|
ORT_LIB_LOCATION = "${patchedOnnxruntime}";
|
||||||
ORT_ENV_SYSTEM_LIB_LOCATION = "${pkgs.onnxruntime}/lib";
|
ORT_ENV_SYSTEM_LIB_LOCATION = "${patchedOnnxruntime}/lib";
|
||||||
ORT_ENV_PREFER_DYNAMIC_LINK = true;
|
ORT_ENV_PREFER_DYNAMIC_LINK = true;
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
cmake
|
cmake
|
||||||
|
|||||||
42
patches/ort_env_global_mutex.patch
Normal file
42
patches/ort_env_global_mutex.patch
Normal 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
|
||||||
Reference in New Issue
Block a user