Skip to content

Commit fcac155

Browse files
Gerold103kyukhin
authored andcommitted
test: don't use not aligned size for mempool
Mempool expects aligned object size. Because it uses the free blocks to store metadata in them, in a struct mslab. Which needs alignment. Part of tarantool/tarantool#5063
1 parent 34eb29d commit fcac155

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/mempool.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "trivia/util.h"
12
#include <small/mempool.h>
23
#include <small/quota.h>
34
#include <stdio.h>
@@ -121,6 +122,12 @@ int main()
121122
objsize = rand() % OBJSIZE_MAX;
122123
if (objsize < OBJSIZE_MIN)
123124
objsize = OBJSIZE_MIN;
125+
/*
126+
* Mempool does not work with not aligned sizes. Because
127+
* it utilizes the unused blocks for storing internal
128+
* info, which needs alignment.
129+
*/
130+
objsize = small_align(objsize, alignof(uint64_t));
124131

125132
quota_init(&quota, UINT_MAX);
126133

0 commit comments

Comments
 (0)