Index: libcfa/src/bits/locks.hfa
===================================================================
--- libcfa/src/bits/locks.hfa	(revision c1581a019144f826aca6008d43a76d4bbbdd99a7)
+++ libcfa/src/bits/locks.hfa	(revision e68d09236d814efe89f3e680ef44217ed691df67)
@@ -112,4 +112,9 @@
 	#endif
 
+	extern "C" {
+		char * strerror(int);
+	}
+	#define CHECKED(x) { int err = x; if( err != 0 ) abort("KERNEL ERROR: %s\n", strerror(err)); }
+
 	struct __bin_sem_t {
 		pthread_mutex_t 	lock;
@@ -119,22 +124,27 @@
 
 	static inline void ?{}(__bin_sem_t & this) with( this ) {
-		pthread_mutex_init(&lock, NULL);
-		pthread_cond_init (&cond, NULL);
+		// Create the mutex with error checking
+		pthread_mutexattr_t mattr;
+		pthread_mutexattr_init( &mattr );
+		pthread_mutexattr_settype( &mattr, PTHREAD_MUTEX_ERRORCHECK_NP);
+		pthread_mutex_init(&lock, &mattr);
+
+		pthread_cond_init (&cond, 0p);
 		val = 0;
 	}
 
 	static inline void ^?{}(__bin_sem_t & this) with( this ) {
-		pthread_mutex_destroy(&lock);
-		pthread_cond_destroy (&cond);
+		CHECKED( pthread_mutex_destroy(&lock) );
+		CHECKED( pthread_cond_destroy (&cond) );
 	}
 
 	static inline void wait(__bin_sem_t & this) with( this ) {
 		verify(__cfaabi_dbg_in_kernel());
-		pthread_mutex_lock(&lock);
+		CHECKED( pthread_mutex_lock(&lock) );
 			while(val < 1) {
 				pthread_cond_wait(&cond, &lock);
 			}
 			val -= 1;
-		pthread_mutex_unlock(&lock);
+		CHECKED( pthread_mutex_unlock(&lock) );
 	}
 
@@ -142,5 +152,5 @@
 		bool needs_signal = false;
 
-		pthread_mutex_lock(&lock);
+		CHECKED( pthread_mutex_lock(&lock) );
 			if(val < 1) {
 				val += 1;
@@ -148,7 +158,9 @@
 				needs_signal = true;
 			}
-		pthread_mutex_unlock(&lock);
+		CHECKED( pthread_mutex_unlock(&lock) );
 
 		return needs_signal;
 	}
+
+	#undef CHECKED
 #endif
