Skip to content

Commit f04168c

Browse files
committed
Add integer overflow tests
1 parent d69a241 commit f04168c

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

.github/workflows/reusable_sanitizers.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ jobs:
7373
7474
- name: Run tests
7575
working-directory: ${{env.BUILD_DIR}}
76+
env:
77+
ASAN_OPTIONS: allocator_may_return_null=1
78+
TSAN_OPTIONS: allocator_may_return_null=1
7679
run: |
7780
${{ matrix.compiler.cxx == 'icpx' && '. /opt/intel/oneapi/setvars.sh' || true }}
7881
ctest --output-on-failure
@@ -141,4 +144,7 @@ jobs:
141144

142145
- name: Run tests
143146
working-directory: ${{env.BUILD_DIR}}
147+
env:
148+
ASAN_OPTIONS: allocator_may_return_null=1
149+
TSAN_OPTIONS: allocator_may_return_null=1
144150
run: ctest -C Debug --output-on-failure

test/poolFixtures.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,9 @@ TEST_P(umfPoolTest, realloc_compliance) {
451451

452452
TEST_P(umfPoolTest, free_compliance) { free_compliance_test(pool.get()); }
453453

454+
TEST_P(umfPoolTest, allocMaxSize) {
455+
auto *ptr = umfPoolMalloc(pool.get(), SIZE_MAX);
456+
ASSERT_EQ(ptr, nullptr);
457+
}
458+
454459
#endif /* UMF_TEST_POOL_FIXTURES_HPP */

test/provider_os_memory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ TEST_P(umfProviderTest, alloc_WRONG_SIZE) {
260260
UMF_OS_RESULT_ERROR_ALLOC_FAILED);
261261
}
262262

263+
TEST_P(umfProviderTest, alloc_MAX_SIZE) {
264+
test_alloc_failure(provider.get(), SIZE_MAX, 0,
265+
UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC,
266+
UMF_OS_RESULT_ERROR_ALLOC_FAILED);
267+
}
268+
263269
// other positive tests
264270

265271
TEST_P(umfProviderTest, get_min_page_size) {

test/provider_os_memory_multiple_numa_nodes.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,3 +774,21 @@ TEST_F(testNuma, checkModeInterleaveIllegalArgSet) {
774774
ASSERT_EQ(umf_result, UMF_RESULT_ERROR_INVALID_ARGUMENT);
775775
ASSERT_EQ(os_memory_provider, nullptr);
776776
}
777+
778+
// Interleave mode set with SIZE_MAX part size
779+
TEST_F(testNuma, maxPartSize) {
780+
std::vector<unsigned> numa_nodes = get_available_numa_nodes();
781+
782+
umf_os_memory_provider_params_t os_memory_provider_params =
783+
UMF_OS_MEMORY_PROVIDER_PARAMS_TEST;
784+
os_memory_provider_params.numa_mode = UMF_NUMA_MODE_INTERLEAVE;
785+
os_memory_provider_params.part_size = SIZE_MAX;
786+
os_memory_provider_params.numa_list = numa_nodes.data();
787+
os_memory_provider_params.numa_list_len = numa_nodes.size();
788+
789+
auto res = umfMemoryProviderCreate(umfOsMemoryProviderOps(),
790+
&os_memory_provider_params,
791+
&os_memory_provider);
792+
ASSERT_EQ(res, UMF_RESULT_ERROR_INVALID_ARGUMENT);
793+
ASSERT_EQ(os_memory_provider, nullptr);
794+
}

test/test_valgrind.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ for test in $(ls -1 umf_test-*); do
125125
umf_test-memspace_lowest_latency)
126126
FILTER='--gtest_filter="-*allocLocalMt*"'
127127
;;
128+
umf_test-memoryPool)
129+
FILTER='--gtest_filter="-*allocMaxSize*"'
130+
;;
128131
esac
129132

130133
[ "$FILTER" != "" ] && echo -n "($FILTER) "

0 commit comments

Comments
 (0)