Skip to content

Commit 2e53465

Browse files
committed
Fix disjoint_pool unit tests
The UMF tests should not use the default system allocator to allocate memory, because they may not work correctly under the UMF proxy library when they and the proxy library are dynamically linked with the same libumf.so file. In such case the same tracker is used in both: the test and the proxy library, so there may be conflicts of memory allocations. An allocation made originally by the the default system allocator in the test is first added to the tracker by the proxy library (which replaced the system allocator) and then the test itself tries to add the same pointer to the same tracker in the tracking provider of the pool that had made this allocation. Fixes: #240 Signed-off-by: Lukasz Dorau <[email protected]>
1 parent d3daaf6 commit 2e53465

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/pools/disjoint_pool.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2023-2024 Intel Corporation
1+
// Copyright (C) 2023-2025 Intel Corporation
22
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

@@ -61,14 +61,14 @@ TEST_F(test, freeErrorPropagation) {
6161
static umf_result_t expectedResult = UMF_RESULT_SUCCESS;
6262
struct memory_provider : public umf_test::provider_base_t {
6363
umf_result_t alloc(size_t size, size_t, void **ptr) noexcept {
64-
*ptr = malloc(size);
64+
*ptr = umf_ba_global_alloc(size);
6565
return UMF_RESULT_SUCCESS;
6666
}
6767

6868
umf_result_t free(void *ptr, [[maybe_unused]] size_t size) noexcept {
6969
// do the actual free only when we expect the success
7070
if (expectedResult == UMF_RESULT_SUCCESS) {
71-
::free(ptr);
71+
umf_ba_global_free(ptr);
7272
}
7373
return expectedResult;
7474
}
@@ -114,12 +114,12 @@ TEST_F(test, sharedLimits) {
114114

115115
struct memory_provider : public umf_test::provider_base_t {
116116
umf_result_t alloc(size_t size, size_t, void **ptr) noexcept {
117-
*ptr = malloc(size);
117+
*ptr = umf_ba_global_alloc(size);
118118
numAllocs++;
119119
return UMF_RESULT_SUCCESS;
120120
}
121121
umf_result_t free(void *ptr, [[maybe_unused]] size_t size) noexcept {
122-
::free(ptr);
122+
umf_ba_global_free(ptr);
123123
numFrees++;
124124
return UMF_RESULT_SUCCESS;
125125
}

0 commit comments

Comments
 (0)