Index: uspace/lib/c/generic/malloc.c
===================================================================
--- uspace/lib/c/generic/malloc.c	(revision c263c77c4712f982349c184bbee4df2163f68baa)
+++ uspace/lib/c/generic/malloc.c	(revision 0c33b1d5be2221765dabe9e2b48eb3936a0f1464)
@@ -119,4 +119,13 @@
 	    (((uintptr_t) (head)) + (head)->size - sizeof(heap_block_foot_t)))
 
+#define malloc_assert(expr) \
+	do { \
+		if (!(expr)) {\
+			futex_up(&malloc_futex); \
+			assert((expr)); \
+		} \
+	} while (0)
+
+
 /** Heap area.
  *
@@ -228,10 +237,10 @@
 	heap_block_head_t *head = (heap_block_head_t *) addr;
 	
-	assert(head->magic == HEAP_BLOCK_HEAD_MAGIC);
+	malloc_assert(head->magic == HEAP_BLOCK_HEAD_MAGIC);
 	
 	heap_block_foot_t *foot = BLOCK_FOOT(head);
 	
-	assert(foot->magic == HEAP_BLOCK_FOOT_MAGIC);
-	assert(head->size == foot->size);
+	malloc_assert(foot->magic == HEAP_BLOCK_FOOT_MAGIC);
+	malloc_assert(head->size == foot->size);
 }
 
@@ -247,9 +256,9 @@
 	heap_area_t *area = (heap_area_t *) addr;
 	
-	assert(area->magic == HEAP_AREA_MAGIC);
-	assert(addr == area->start);
-	assert(area->start < area->end);
-	assert(((uintptr_t) area->start % PAGE_SIZE) == 0);
-	assert(((uintptr_t) area->end % PAGE_SIZE) == 0);
+	malloc_assert(area->magic == HEAP_AREA_MAGIC);
+	malloc_assert(addr == area->start);
+	malloc_assert(area->start < area->end);
+	malloc_assert(((uintptr_t) area->start % PAGE_SIZE) == 0);
+	malloc_assert(((uintptr_t) area->end % PAGE_SIZE) == 0);
 }
 
@@ -382,5 +391,5 @@
 	
 	block_check((void *) last_head);
-	assert(last_head->area == area);
+	malloc_assert(last_head->area == area);
 	
 	if (last_head->free) {
@@ -395,5 +404,5 @@
 		
 		block_check((void *) first_head);
-		assert(first_head->area == area);
+		malloc_assert(first_head->area == area);
 		
 		size_t shrink_size = ALIGN_DOWN(last_head->size, PAGE_SIZE);
@@ -497,5 +506,5 @@
 static void split_mark(heap_block_head_t *cur, const size_t size)
 {
-	assert(cur->size >= size);
+	malloc_assert(cur->size >= size);
 	
 	/* See if we should split the block. */
@@ -533,6 +542,6 @@
 {
 	area_check((void *) area);
-	assert((void *) first_block >= (void *) AREA_FIRST_BLOCK_HEAD(area));
-	assert((void *) first_block < area->end);
+	malloc_assert((void *) first_block >= (void *) AREA_FIRST_BLOCK_HEAD(area));
+	malloc_assert((void *) first_block < area->end);
 	
 	for (heap_block_head_t *cur = first_block; (void *) cur < area->end;
@@ -661,5 +670,5 @@
 static void *malloc_internal(const size_t size, const size_t align)
 {
-	assert(first_heap_area != NULL);
+	malloc_assert(first_heap_area != NULL);
 	
 	if (align == 0)
@@ -786,11 +795,11 @@
 	
 	block_check(head);
-	assert(!head->free);
+	malloc_assert(!head->free);
 	
 	heap_area_t *area = head->area;
 	
 	area_check(area);
-	assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area));
-	assert((void *) head < area->end);
+	malloc_assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area));
+	malloc_assert((void *) head < area->end);
 	
 	void *ptr = NULL;
@@ -863,11 +872,11 @@
 	
 	block_check(head);
-	assert(!head->free);
+	malloc_assert(!head->free);
 	
 	heap_area_t *area = head->area;
 	
 	area_check(area);
-	assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area));
-	assert((void *) head < area->end);
+	malloc_assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area));
+	malloc_assert((void *) head < area->end);
 	
 	/* Mark the block itself as free. */
