Index: kernel/generic/include/adt/cht.h
===================================================================
--- kernel/generic/include/adt/cht.h	(revision d04e46e733c1ef74eb93b6fc924b1cd286dd4502)
+++ kernel/generic/include/adt/cht.h	(revision 3ac5086e0b5b6d93c26f2b1c150344366e5478e8)
@@ -136,4 +136,5 @@
 	size_t max_load, bool can_block, cht_ops_t *op);
 extern void cht_destroy(cht_t *h);
+extern void cht_destroy_unsafe(cht_t *h);
 
 extern cht_link_t *cht_find(cht_t *h, void *key);
Index: kernel/generic/include/proc/task.h
===================================================================
--- kernel/generic/include/proc/task.h	(revision d04e46e733c1ef74eb93b6fc924b1cd286dd4502)
+++ kernel/generic/include/proc/task.h	(revision 3ac5086e0b5b6d93c26f2b1c150344366e5478e8)
@@ -129,12 +129,12 @@
 	task_arch_t arch;
 	
-	/** Serializes access to futex_list (independent of the task spinlock). */
-	mutex_t futex_list_lock;
-	/** List of all futexes accesses by this task. */
-	list_t futex_list;
-	/** CHT mapping virtual addresses of futex variables to futex objects. */
 	struct futex_cache {
+		/** CHT mapping virtual addresses of futex variables to futex objects.*/
+		cht_t ht;
+		/** Serializes access to futex_list.*/
+		mutex_t list_lock;
+		/** List of all futexes accesses by this task. */
+		list_t list;
 		work_t destroy_work;
-		cht_t ht;
 	} *futexes;
 	
Index: kernel/generic/src/adt/cht.c
===================================================================
--- kernel/generic/src/adt/cht.c	(revision d04e46e733c1ef74eb93b6fc924b1cd286dd4502)
+++ kernel/generic/src/adt/cht.c	(revision 3ac5086e0b5b6d93c26f2b1c150344366e5478e8)
@@ -617,4 +617,13 @@
 void cht_destroy(cht_t *h)
 {
+	cht_destroy_unsafe(h);
+	
+	/* You must clear the table of items. Otherwise cht_destroy will leak. */
+	ASSERT(atomic_get(&h->item_cnt) == 0);
+}
+
+/** Destroys a successfully created CHT but does no error checking. */
+void cht_destroy_unsafe(cht_t *h)
+{
 	/* Wait for resize to complete. */
 	while (0 < atomic_get(&h->resize_reqs)) {
@@ -627,7 +636,4 @@
 	free(h->b);
 	h->b = NULL;
-	
-	/* You must clear the table of items. Otherwise cht_destroy will leak. */
-	ASSERT(atomic_get(&h->item_cnt) == 0);
 }
 
Index: kernel/generic/src/proc/task.c
===================================================================
--- kernel/generic/src/proc/task.c	(revision d04e46e733c1ef74eb93b6fc924b1cd286dd4502)
+++ kernel/generic/src/proc/task.c	(revision 3ac5086e0b5b6d93c26f2b1c150344366e5478e8)
@@ -165,8 +165,5 @@
 	spinlock_initialize(&task->active_calls_lock, "active_calls_lock");
 	list_initialize(&task->active_calls);
-	
-	mutex_initialize(&task->futex_list_lock, MUTEX_PASSIVE);
-	list_initialize(&task->futex_list);
-	
+		
 #ifdef CONFIG_UDEBUG
 	/* Init kbox stuff */
Index: kernel/generic/src/synch/futex.c
===================================================================
--- kernel/generic/src/synch/futex.c	(revision d04e46e733c1ef74eb93b6fc924b1cd286dd4502)
+++ kernel/generic/src/synch/futex.c	(revision 3ac5086e0b5b6d93c26f2b1c150344366e5478e8)
@@ -158,8 +158,11 @@
 	
 	cht_create(&task->futexes->ht, 0, 0, 0, true, &task_futex_ht_ops);
+	
+	list_initialize(&task->futexes->list);
+	mutex_initialize(&task->futexes->list_lock, MUTEX_PASSIVE);
 }
 
 /** Destroys the futex structures for the dying task. */
-void futex_task_deinit(struct task *task)
+void futex_task_deinit(task_t *task)
 {
 	/* Interrupts are disabled so we must not block (cannot run cht_destroy). */
@@ -180,5 +183,18 @@
 		member_to_inst(work, struct futex_cache, destroy_work);
 	
-	cht_destroy(&cache->ht);
+	/* 
+	 * Destroy the cache before manually freeing items of the cache in case
+	 * table resize is in progress.
+	 */
+	cht_destroy_unsafe(&cache->ht);
+	
+	/* Manually free futex_ptr cache items. */
+	list_foreach_safe(cache->list, cur_link, next_link) {
+		futex_ptr_t *fut_ptr = member_to_inst(cur_link, futex_ptr_t, all_link);
+
+		list_remove(cur_link);
+		free(fut_ptr);
+	}
+	
 	free(cache);
 }
@@ -187,10 +203,12 @@
 void futex_task_cleanup(void)
 {
+	struct futex_cache *futexes = TASK->futexes;
+	
 	/* All threads of this task have terminated. This is the last thread. */
-	mutex_lock(&TASK->futex_list_lock);
-	
-	list_foreach_safe(TASK->futex_list, cur_link, next_link) {
-		futex_ptr_t *fut_ptr = member_to_inst(cur_link, futex_ptr_t, cht_link);
-		
+	mutex_lock(&futexes->list_lock);
+	
+	list_foreach_safe(futexes->list, cur_link, next_link) {
+		futex_ptr_t *fut_ptr = member_to_inst(cur_link, futex_ptr_t, all_link);
+
 		/*
 		 * The function is free to free the futex. All other threads of this
@@ -202,14 +220,7 @@
 		 */
 		futex_release_ref_locked(fut_ptr->futex);
-		
-		/* 
-		 * No need to remove the futex_ptr from the CHT cache of this task
-		 * because futex_task_deinit() will destroy the CHT shortly.
-		 */
-		list_remove(cur_link);
-		free(fut_ptr);
-	}
-	
-	mutex_unlock(&TASK->futex_list_lock);
+	}
+	
+	mutex_unlock(&futexes->list_lock);
 }
 
@@ -355,7 +366,7 @@
 	/* Cache the mapping from the virtual address to the futex for this task. */
 	if (cht_insert_unique(&TASK->futexes->ht, &fut_ptr->cht_link, &dup_link)) {
-		mutex_lock(&TASK->futex_list_lock);
-		list_append(&fut_ptr->all_link, &TASK->futex_list);
-		mutex_unlock(&TASK->futex_list_lock);
+		mutex_lock(&TASK->futexes->list_lock);
+		list_append(&fut_ptr->all_link, &TASK->futexes->list);
+		mutex_unlock(&TASK->futexes->list_lock);
 	} else {
 		/* Another thread of this task beat us to it. Use that mapping instead.*/
