Avoid race on reading alignment in for-loop

This commit is contained in:
Lysandros Nikolaou 2025-03-06 13:51:26 +01:00
parent 10104eb5aa
commit 308e1fc93d
No known key found for this signature in database
GPG Key ID: 43E92D11D08F5F29
2 changed files with 2 additions and 2 deletions

View File

@ -201,7 +201,7 @@ extern struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT + 1];
* statically-allocated. This is necessary to properly handle stats. * statically-allocated. This is necessary to properly handle stats.
*/ */
#define IMAGING_ARENAS_FOREACH(arena) \ #define IMAGING_ARENAS_FOREACH(arena) \
for ((arena) = &ImagingArenas[0]; (arena)->alignment >= 0; ++(arena)) for ((arena) = &ImagingArenas[0]; (arena)->index >= 0; ++(arena))
#else #else
/* In this case we either have the GIL or do not have thread-local storage, in /* In this case we either have the GIL or do not have thread-local storage, in
* which case we will only allocate a single arena. * which case we will only allocate a single arena.

View File

@ -282,7 +282,7 @@ struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT + 1] = {
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 5, {0}}, {1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 5, {0}},
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 6, {0}}, {1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 6, {0}},
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 7, {0}}, {1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 7, {0}},
{-1}, {1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, -1, {0}},
}; };
/* Get a pointer to the correct arena for this context. In this case where we /* Get a pointer to the correct arena for this context. In this case where we