From 0b47145526f3489ec6932b9b3a36f2a961a2b88e Mon Sep 17 00:00:00 2001 From: Nathaniel Filardo Date: Mon, 13 May 2019 12:50:31 +0100 Subject: [PATCH] test/func/malloc: posix_memalign vs. size_t posix_memalign requires that the alignment parameter be a multiple of sizeof(uintptr_t), but the test begins with alignments as small as sizeof(size_t). While those are very likely the same value out in the wild right now, they're not on CHERI. Begin the test loop at sizeof(uintptr_t) and add a test that a request for a reasonable amount of memory but with an alignment of sizeof(uintptr_t)/2 fails with EINVAL. --- src/test/func/malloc/malloc.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/func/malloc/malloc.cc b/src/test/func/malloc/malloc.cc index 8df3455..a2d8600 100644 --- a/src/test/func/malloc/malloc.cc +++ b/src/test/func/malloc/malloc.cc @@ -106,8 +106,9 @@ int main(int argc, char** argv) test_posix_memalign(0, 0, EINVAL, true); test_posix_memalign((size_t)-1, 0, EINVAL, true); + test_posix_memalign(OS_PAGE_SIZE, sizeof(uintptr_t) / 2, EINVAL, true); - for (size_t align = sizeof(size_t); align <= SUPERSLAB_SIZE; align <<= 1) + for (size_t align = sizeof(uintptr_t); align <= SUPERSLAB_SIZE; align <<= 1) { for (snmalloc::sizeclass_t sc = 0; sc < NUM_SIZECLASSES; sc++) {