From 7f3e5400df81838863e41c5453cbe1e83c2d428f Mon Sep 17 00:00:00 2001 From: lbonn Date: Tue, 2 Apr 2024 12:55:33 +0200 Subject: [PATCH] Backport of pcre2-10.44-Fix-locking-region.patch Cherry-picked from ad89dd8ecd25589d236bd20b36f2abf69f938fd1 (https://github.com/zherczeg/sljit.git) Fix locking region in sjlit_malloc_exec The locked section needs to extend until we are done modifying internal block offsets and sizes, otherwise we risk running into data corruption in a multi-threaded context. This bug was introduced in 7de0fee9a7376b33e31a3903487cd9933da3a606 --- src/sljit/allocator_src/sljitExecAllocatorCore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sljit/allocator_src/sljitExecAllocatorCore.c b/src/sljit/allocator_src/sljitExecAllocatorCore.c index 6cd39110..4ef39c17 100644 --- a/src/sljit/allocator_src/sljitExecAllocatorCore.c +++ b/src/sljit/allocator_src/sljitExecAllocatorCore.c @@ -237,12 +237,12 @@ SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size) header->size = chunk_size; next_header = AS_BLOCK_HEADER(header, chunk_size); } - SLJIT_ALLOCATOR_UNLOCK(); next_header->size = 1; next_header->prev_size = chunk_size; #ifdef SLJIT_HAS_EXECUTABLE_OFFSET next_header->executable_offset = executable_offset; #endif /* SLJIT_HAS_EXECUTABLE_OFFSET */ + SLJIT_ALLOCATOR_UNLOCK(); return MEM_START(header); } -- 2.56.0