From 7a50361208ad0ed5436a5f8a9e32cfa6675e722e Mon Sep 17 00:00:00 2001 From: amancini-N Date: Fri, 23 Aug 2024 15:15:47 +0000 Subject: [PATCH 1/2] Fix "./onnxruntime_test_all --help" segfault --- onnxruntime/test/unittest_main/test_main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/test/unittest_main/test_main.cc b/onnxruntime/test/unittest_main/test_main.cc index b558a7f00f7bc..bee562c3f42e4 100644 --- a/onnxruntime/test/unittest_main/test_main.cc +++ b/onnxruntime/test/unittest_main/test_main.cc @@ -92,8 +92,8 @@ int TEST_MAIN(int argc, char** argv) { int status = 0; ORT_TRY { - ortenv_setup(); ::testing::InitGoogleTest(&argc, argv); + ortenv_setup(); status = RUN_ALL_TESTS(); } From 85437a08131f0fca35219ed5d3e3f7f9cd66fd0c Mon Sep 17 00:00:00 2001 From: amancini-N Date: Mon, 18 Nov 2024 14:56:43 +0000 Subject: [PATCH 2/2] Restore setup order and always do teardown at exit --- onnxruntime/test/unittest_main/test_main.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/onnxruntime/test/unittest_main/test_main.cc b/onnxruntime/test/unittest_main/test_main.cc index bee562c3f42e4..1b61530645fb1 100644 --- a/onnxruntime/test/unittest_main/test_main.cc +++ b/onnxruntime/test/unittest_main/test_main.cc @@ -92,8 +92,10 @@ int TEST_MAIN(int argc, char** argv) { int status = 0; ORT_TRY { - ::testing::InitGoogleTest(&argc, argv); ortenv_setup(); + // TODO: Fix the C API issue + atexit(ortenv_teardown); // If we don't do this, it will crash + ::testing::InitGoogleTest(&argc, argv); status = RUN_ALL_TESTS(); } @@ -104,9 +106,6 @@ int TEST_MAIN(int argc, char** argv) { }); } - // TODO: Fix the C API issue - ortenv_teardown(); // If we don't do this, it will crash - #ifndef USE_ONNXRUNTIME_DLL // make memory leak checker happy ::google::protobuf::ShutdownProtobufLibrary();