From a280694457152abbbf86c8e502b7f933dae40763 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 10 Jul 2022 20:05:12 +0700 Subject: [PATCH 1/2] run memory leaks tests only with Debug CRT --- .../std/tests/Dev10_908702_string_memory_leak/test.cpp | 10 +++------- .../Dev11_0485243_condition_variable_crash/test.cpp | 4 ++-- .../test.cpp | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/std/tests/Dev10_908702_string_memory_leak/test.cpp b/tests/std/tests/Dev10_908702_string_memory_leak/test.cpp index 65ef7e531f..6bf4cd733e 100644 --- a/tests/std/tests/Dev10_908702_string_memory_leak/test.cpp +++ b/tests/std/tests/Dev10_908702_string_memory_leak/test.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// REQUIRES: debug_CRT + #include #include #include @@ -20,9 +22,7 @@ int main() { v.insert(v.begin(), 2, "2"); } -#ifdef _DEBUG assert(!_CrtDumpMemoryLeaks()); -#endif { string one("111"); @@ -32,21 +32,17 @@ int main() { two = three; } -#ifdef _DEBUG assert(!_CrtDumpMemoryLeaks()); -#endif // Also test DevDiv-846054 ": Spurious memory leaks". locale::global(locale("")); -#ifdef _DEBUG assert(!_CrtDumpMemoryLeaks()); -#endif } // Also test DevDiv-810608 ": [torino][boost]error C2665: // 'std::_Crt_new_delete::operator new' : none of the 2 overloads could convert all the argument types". -void meow(void* pv) { +void meow(void* pv) { // COMPILE-ONLY // Saying "new" instead of "::new" is intentional here. new (pv) locale(); } diff --git a/tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp b/tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp index 465c1b4c16..4a7ce4a2ed 100644 --- a/tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp +++ b/tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// REQUIRES: debug_CRT + #include #include #include @@ -17,11 +19,9 @@ using namespace std; void assert_no_leaks() { -#ifdef _DEBUG if (_CrtDumpMemoryLeaks()) { abort(); } -#endif } void test_484720(); diff --git a/tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp b/tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp index 268721302d..844be31d86 100644 --- a/tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp +++ b/tests/std/tests/Dev11_0748972_function_crash_out_of_memory/test.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// REQUIRES: debug_CRT + #define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING #include @@ -127,11 +129,9 @@ void test(const int num) { g_allocations_remaining = 1000000; -#ifdef _DEBUG if (_CrtDumpMemoryLeaks()) { abort(); } -#endif return; } From 94768b45e6fc33f907d6b8508001231e5814864e Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 11 Jul 2022 19:22:37 -0700 Subject: [PATCH 2/2] Dev11_0485243_condition_variable_crash tests more than memory leaks. --- .../std/tests/Dev11_0485243_condition_variable_crash/test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp b/tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp index 4a7ce4a2ed..465c1b4c16 100644 --- a/tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp +++ b/tests/std/tests/Dev11_0485243_condition_variable_crash/test.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// REQUIRES: debug_CRT - #include #include #include @@ -19,9 +17,11 @@ using namespace std; void assert_no_leaks() { +#ifdef _DEBUG if (_CrtDumpMemoryLeaks()) { abort(); } +#endif } void test_484720();