From a4538cdcee75b78b7165dda05c9aa7718c4837c4 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 10 Dec 2024 22:02:32 -0800 Subject: [PATCH] [libc++abi] Don't leak in test (#119505) Trying to re-enable a test on bots https://github.com/llvm/llvm-zorg/blob/bb695735dba75e1a5dced13e836f4f46de464bac/zorg/buildbot/builders/sanitizers/buildbot_functions.sh#L443 When we reach `terminate()` `exc` pointer is not on the stack, so lsan correctly reports a leak. --- libcxxabi/test/forced_unwind2.pass.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libcxxabi/test/forced_unwind2.pass.cpp b/libcxxabi/test/forced_unwind2.pass.cpp index 6ec27e4a6555..edd0a3b175f0 100644 --- a/libcxxabi/test/forced_unwind2.pass.cpp +++ b/libcxxabi/test/forced_unwind2.pass.cpp @@ -44,10 +44,8 @@ struct Stop { }; static void forced_unwind() { - _Unwind_Exception* exc = new _Unwind_Exception; - memset(&exc->exception_class, 0, sizeof(exc->exception_class)); - exc->exception_cleanup = 0; - _Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0); + static _Unwind_Exception exc = {}; + _Unwind_ForcedUnwind(&exc, Stop<_Unwind_Stop_Fn>::stop, 0); abort(); }