Skip to content

Commit c8041cf

Browse files
author
Pranav Sharma
authored
Fix OrtEnv creation causing server to hang during shutdown. (#117)
OrtEnv gets created twice in onnx_loader. This causes its refcount to increase to 2. Due to this when ReleaseEnv is called inside ~OnnxLoader, it does nothing other than decrease the refcount to 1. Next all the libraries are unloaded the openvino global context ptr gets unloaded followed by OrtEnv's destructor which now actually does useful work trying to delete the openvno ctx ptr which is not valid any more causing memory corruption.
1 parent 96e1d93 commit c8041cf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/onnxruntime_loader.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <locale>
3232
#include <string>
3333
#include <thread>
34+
3435
#include "onnxruntime_utils.h"
3536

3637
namespace triton { namespace backend { namespace onnxruntime {
@@ -55,9 +56,9 @@ OnnxLoader::Init(common::TritonJson::Value& backend_config)
5556
OrtLoggingLevel logging_level =
5657
TRITONSERVER_LogIsEnabled(TRITONSERVER_LOG_VERBOSE)
5758
? ORT_LOGGING_LEVEL_VERBOSE
58-
: TRITONSERVER_LogIsEnabled(TRITONSERVER_LOG_WARN)
59-
? ORT_LOGGING_LEVEL_WARNING
60-
: ORT_LOGGING_LEVEL_ERROR;
59+
: TRITONSERVER_LogIsEnabled(TRITONSERVER_LOG_WARN)
60+
? ORT_LOGGING_LEVEL_WARNING
61+
: ORT_LOGGING_LEVEL_ERROR;
6162

6263
// Controls whether to enable global threadpool which will be shared across
6364
// sessions. Use this in conjunction with DisablePerSessionThreads API or
@@ -110,7 +111,6 @@ OnnxLoader::Init(common::TritonJson::Value& backend_config)
110111
status = ort_api->CreateEnv(logging_level, "log", &env);
111112
}
112113

113-
status = ort_api->CreateEnv(logging_level, "log", &env);
114114
loader.reset(new OnnxLoader(env, global_threadpool_enabled));
115115
RETURN_IF_ORT_ERROR(status);
116116
} else {

0 commit comments

Comments
 (0)