Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-08-30 03:46:44 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-08-30 03:46:44 +0400
commit9135425607ccb56df9a3210e3ee222650cb74686 (patch)
tree88fd1f4299709fbadec6189faeb7dbe54c6cdc7e /intern/guardedalloc
parent07e655dfa60b0ed524d21b777ffbb14464b18dd9 (diff)
Attempted fix for #36569: couldn't unmap memory errors on Windows. The guardedalloc optimizations were not entirely thread safe for mmap.
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r--intern/guardedalloc/intern/mallocn.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c
index 19e6e880b6a..34e8c79f2fd 100644
--- a/intern/guardedalloc/intern/mallocn.c
+++ b/intern/guardedalloc/intern/mallocn.c
@@ -568,8 +568,15 @@ void *MEM_mapallocN(size_t len, const char *str)
len = (len + 3) & ~3; /* allocate in units of 4 */
+#if defined(WIN32)
+ /* our windows mmap implementation is not thread safe */
+ mem_lock_thread();
+#endif
memh = mmap(NULL, len + sizeof(MemHead) + sizeof(MemTail),
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+#if defined(WIN32)
+ mem_unlock_thread();
+#endif
if (memh != (MemHead *)-1) {
make_memhead_header(memh, len, str);
@@ -957,8 +964,15 @@ static void rem_memblock(MemHead *memh)
if (memh->mmap) {
atomic_sub_z(&mmap_in_use, memh->len);
+#if defined(WIN32)
+ /* our windows mmap implementation is not thread safe */
+ mem_lock_thread();
+#endif
if (munmap(memh, memh->len + sizeof(MemHead) + sizeof(MemTail)))
printf("Couldn't unmap memory %s\n", memh->name);
+#if defined(WIN32)
+ mem_unlock_thread();
+#endif
}
else {
if (malloc_debug_memset && memh->len)