Repository navigation
Description
Following #609. That one was framed around the CUDA EP, and it was closed pointing at #610. Two things here that I think are worth recording, because both surprised me:
- The same teardown crash happens with no EP at all — plain CPU,
default-features = false, features = ["std", "load-dynamic"]. - It is ONNX Runtime version dependent. One binary, three runtimes, and the fault simply stops at 1.23.
And I can confirm your fix works for this variant too.
Repro
Twenty lines, no execution provider, any .onnx:
// ort = { version = "2.0.0-rc.13", default-features = false, features = ["std", "load-dynamic"] }
fn main() {
let path = std::env::args().nth(1).unwrap();
ort::init().with_name("repro").commit();
let session = ort::session::Session::builder().unwrap()
.commit_from_file(&path).unwrap();
if std::env::var("LEAK").is_ok() {
std::mem::forget(session);
} else {
drop(session);
}
println!("end of main");
}$ ORT_DYLIB_PATH=…/libonnxruntime.so ./repro model.onnx
end of main
Segmentation fault (core dumped) # exit 139
$ LEAK=1 ORT_DYLIB_PATH=…/libonnxruntime.so ./repro model.onnx
end of main # exit 0
end of main always prints. The crash is strictly after main returns.
Measurements
Same binary, only ORT_DYLIB_PATH changed:
| ONNX Runtime | exit |
|---|---|
| 1.20.0 | 139 — SIGSEGV |
| 1.22.0 | 139 — SIGSEGV |
| 1.23.2 | 0 |
Ruled out along the way:
ort::init() alone, no session |
exit 0 — not environment creation |
| session created and leaked | exit 0 — needs the session actually destroyed |
intra_threads = 1, 2, 4 |
139 in all three — not the thread pool |
std::process::exit(0) at end of main |
exit 0 |
Inference is correct and complete in every failing case; the scores are byte-identical to the passing ones. Only the exit status differs — which still breaks CI, && chains and process supervisors, and in a long-running server shows up at shutdown.
#610 fixes it
You asked #609's reporter to try the manual-Environment branch. I tried it against the oldest runtime I have, the one that fails hardest on rc.13:
// ort = { git = "https://github.com/pykeio/ort", default-features = false, features = ["std", "load-dynamic"] }
let env = ort::init().with_name("check").build().unwrap();
let session = ort::session::Session::builder(&env).unwrap()
.commit_from_file(&path).unwrap();
drop(session);ort git + onnxruntime 1.20.0 → exit 0
So #610 addresses the CPU-only, version-dependent manifestation as well as the CUDA one — the fix is not EP-specific, which fits your reading that the problem is the global environment being released after the state it refers to is gone.
Why I am writing it down anyway
ORT_API_VERSION is 17, and runtimes far below 1.23 satisfy it. So an old shared library loads without complaint, runs correctly, and then segfaults on the way out — with nothing in the message pointing at the runtime version. Until #610 ships, anyone on rc.13 with load-dynamic and a runtime pulled from, say, a Python onnxruntime wheel a couple of releases old will hit this and have no obvious reason to suspect the .so.
Two things that would have saved me the afternoon, if they appeal to you: a documented minimum runtime version alongside the API level, or a warning at init() when the loaded runtime reports a version below the one the release was built against. Happy to send a PR for either if you would take it.
Environment
ort2.0.0-rc.13,load-dynamic, no EP features- ONNX Runtime 1.20.0 / 1.22.0 / 1.23.2, all
load-dynamicviaORT_DYLIB_PATH - rustc 1.88.0, Ubuntu 22.04.5, glibc 2.35, kernel 5.15, x86_64
No debugger on that host, so no backtrace — the static-link path does not build there either (ort-sys wants a newer libstdc++ than 22.04 ships). If a stack from this specific configuration is useful I can arrange one on a machine with gdb.
Activity
docs: require ONNX Runtime 1.23 or newer
docs: require ONNX Runtime 1.23 or newer
decahedron1 commentedon Aug 25, 2026
Thank you for confirming #610 fixed it!
fix: repair the ONNX feature surface (onnx / onnx-reload / mc-live-bu…