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:
authorCampbell Barton <ideasman42@gmail.com>2012-12-12 08:41:23 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-12-12 08:41:23 +0400
commit21a2660290fd74da5adea6df944922180ffe6c91 (patch)
tree626c913fd6c7d05e67206ad6ffc6637cfa922398 /intern/guardedalloc
parentc40030a36ce61cd6d4158e129fe8e5a17ac33bc5 (diff)
assert in debug builds if MEM_ alloc's are called in openmp threads.
note: the caller can do locking to prevent errors - but this isn't being done in blender yet, so this prevents accidental allocs in openmp for now.
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r--intern/guardedalloc/intern/mallocn.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c
index 4a79f5d0de1..59e780f21e5 100644
--- a/intern/guardedalloc/intern/mallocn.c
+++ b/intern/guardedalloc/intern/mallocn.c
@@ -110,6 +110,15 @@ typedef struct MemHead {
#endif
} MemHead;
+/* for openmp threading asserts, saves time troubleshooting
+ * we may need to extend this if blender code starts using MEM_
+ * functions inside OpenMP correctly with omp_set_lock() */
+#if defined(_OPENMP) && defined(DEBUG)
+# include <assert.h>
+# include <omp.h>
+# define DEBUG_OMP_MALLOC
+#endif
+
typedef struct MemTail {
int tag3, pad;
} MemTail;
@@ -194,6 +203,10 @@ static void print_error(const char *str, ...)
static void mem_lock_thread(void)
{
+#ifdef DEBUG_OMP_MALLOC
+ assert(omp_in_parallel() == 0);
+#endif
+
if (thread_lock_callback)
thread_lock_callback();
}
@@ -214,8 +227,7 @@ int MEM_check_memory_integrity(void)
err_val = check_memlist(listend);
- if (err_val == NULL) return 0;
- return 1;
+ return (err_val != NULL);
}