Skip to content

[libc++][test] Fix new_delete_resource.pass.cpp by passing correct size to deallocate #93126

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

Closed
wants to merge 1 commit into from

Conversation

cpplearner
Copy link
Contributor

@cpplearner cpplearner commented May 23, 2024

memory_resource requires that the value passed to deallocate matches the argument of allocate ([mem.res.private]/4). Apparently this matters for ASAN (see https://lab.llvm.org/buildbot/#/builders/168/builds/20464).

@cpplearner cpplearner requested a review from a team as a code owner May 23, 2024 02:43
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 23, 2024
@llvmbot
Copy link
Member

llvmbot commented May 23, 2024

@llvm/pr-subscribers-libcxx

Author: S. B. Tam (cpplearner)

Changes

memory_resource requires that the value passed to deallocate matches the argument of allocate ([[mem.res.private]/4](http://eel.is/c++draft/mem.res.private#4)). Apparently this matters for ASAN.


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

1 Files Affected:

  • (modified) libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp (+1-1)
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp
index 68a82f6ce90b3..7b3107029d4d8 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.global/new_delete_resource.pass.cpp
@@ -76,7 +76,7 @@ void test_allocate_deallocate() {
   ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkOutstandingNewEq(1));
   ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkLastNewSizeEq(50));
 
-  r1.deallocate(ret, 1);
+  r1.deallocate(ret, 50);
   assert(globalMemCounter.checkOutstandingNewEq(0));
   ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(globalMemCounter.checkDeleteCalledEq(1));
 }

@cpplearner
Copy link
Contributor Author

dup of #93145

@cpplearner cpplearner closed this May 23, 2024
@cpplearner cpplearner deleted the cpplearner-patch-1 branch May 23, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants