[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59650] trunk/blender/intern/guardedalloc/ intern/mallocn.c: Attempted fix for #36569: couldn' t unmap memory errors on Windows.

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Aug 30 01:46:44 CEST 2013


Revision: 59650
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59650
Author:   blendix
Date:     2013-08-29 23:46:44 +0000 (Thu, 29 Aug 2013)
Log Message:
-----------
Attempted fix for #36569: couldn't unmap memory errors on Windows. The guardedalloc optimizations were not entirely thread safe for mmap.

Modified Paths:
--------------
    trunk/blender/intern/guardedalloc/intern/mallocn.c

Modified: trunk/blender/intern/guardedalloc/intern/mallocn.c
===================================================================
--- trunk/blender/intern/guardedalloc/intern/mallocn.c	2013-08-29 23:31:30 UTC (rev 59649)
+++ trunk/blender/intern/guardedalloc/intern/mallocn.c	2013-08-29 23:46:44 UTC (rev 59650)
@@ -568,8 +568,15 @@
 
 	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 @@
 
 	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)




More information about the Bf-blender-cvs mailing list