Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++abi] Don't leak in test #119505

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

vitalybuka
Copy link
Collaborator

@vitalybuka vitalybuka commented Dec 11, 2024

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 report a leak.

Created using spr 1.3.4
@vitalybuka vitalybuka requested a review from a team as a code owner December 11, 2024 05:23
@llvmbot llvmbot added the libc++abi libc++abi C++ Runtime Library. Not libc++. label Dec 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 11, 2024

@llvm/pr-subscribers-libcxxabi

Author: Vitaly Buka (vitalybuka)

Changes

Trying to re-enable few tests on bot
https://github.com/llvm/llvm-zorg/blob/bb695735dba75e1a5dced13e836f4f46de464bac/zorg/buildbot/builders/sanitizers/buildbot_functions.sh#L443

forced_unwind3.pass.cpp does not trigger a leak,
but lsan can have false negatives, and the pattern
is the same.


Full diff: https://github.com/llvm/llvm-project/pull/119505.diff

2 Files Affected:

  • (modified) libcxxabi/test/forced_unwind2.pass.cpp (+5-1)
  • (modified) libcxxabi/test/forced_unwind3.pass.cpp (+5-1)
diff --git a/libcxxabi/test/forced_unwind2.pass.cpp b/libcxxabi/test/forced_unwind2.pass.cpp
index 6ec27e4a655577..8dbc8242b7f2ab 100644
--- a/libcxxabi/test/forced_unwind2.pass.cpp
+++ b/libcxxabi/test/forced_unwind2.pass.cpp
@@ -43,10 +43,14 @@ struct Stop<R (*)(Args...)> {
   }
 };
 
+static void cleanup(_Unwind_Reason_Code, struct _Unwind_Exception* exc) {
+  delete exc;
+}
+
 static void forced_unwind() {
   _Unwind_Exception* exc = new _Unwind_Exception;
   memset(&exc->exception_class, 0, sizeof(exc->exception_class));
-  exc->exception_cleanup = 0;
+  exc->exception_cleanup = cleanup;
   _Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0);
   abort();
 }
diff --git a/libcxxabi/test/forced_unwind3.pass.cpp b/libcxxabi/test/forced_unwind3.pass.cpp
index e852ab592292f4..bfb082b702f6a7 100644
--- a/libcxxabi/test/forced_unwind3.pass.cpp
+++ b/libcxxabi/test/forced_unwind3.pass.cpp
@@ -60,10 +60,14 @@ struct Stop<R (*)(Args...)> {
   }
 };
 
+static void cleanup(_Unwind_Reason_Code, struct _Unwind_Exception* exc) {
+  delete exc;
+}
+
 static void forced_unwind() {
   _Unwind_Exception* exc = new _Unwind_Exception;
   memset(&exc->exception_class, 0, sizeof(exc->exception_class));
-  exc->exception_cleanup = 0;
+  exc->exception_cleanup = cleanup;
   _Unwind_ForcedUnwind(exc, Stop<_Unwind_Stop_Fn>::stop, 0);
   abort();
 }

@vitalybuka vitalybuka marked this pull request as draft December 11, 2024 05:26
Copy link

github-actions bot commented Dec 11, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Created using spr 1.3.4
@vitalybuka vitalybuka changed the title [libc++abi] Don't leak in tests [libc++abi] Don't leak in test Dec 11, 2024
@vitalybuka vitalybuka marked this pull request as ready for review December 11, 2024 05:39
@vitalybuka vitalybuka requested a review from MaskRay December 11, 2024 05:39
@vitalybuka vitalybuka merged commit a4538cd into main Dec 11, 2024
34 of 36 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/libcabi-dont-leak-in-tests branch December 11, 2024 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++abi libc++abi C++ Runtime Library. Not libc++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants