jobcore/pcre2/fix-thread-safety.patch

33 lines
1.3 KiB
Diff

From ad89dd8ecd25589d236bd20b36f2abf69f938fd1 Mon Sep 17 00:00:00 2001
From: lbonn <lbonn@users.noreply.github.com>
Date: Tue, 2 Apr 2024 12:55:33 +0200
Subject: [PATCH] Fix locking region in sjlit_malloc_exec (#244)
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
---
sljit_src/allocator_src/sljitExecAllocatorCore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sljit_src/allocator_src/sljitExecAllocatorCore.c b/sljit_src/allocator_src/sljitExecAllocatorCore.c
index 32c29fb6..4e1119bc 100644
--- a/sljit_src/allocator_src/sljitExecAllocatorCore.c
+++ b/sljit_src/allocator_src/sljitExecAllocatorCore.c
@@ -235,12 +235,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);
}