Index: libcfa/src/concurrency/kernel.cfa
===================================================================
--- libcfa/src/concurrency/kernel.cfa	(revision 121be3ed70e29539bf3a9380cf584b566c77a51d)
+++ libcfa/src/concurrency/kernel.cfa	(revision 1def18bbb819e16e167e9992eb88901d5d8ec5f4)
@@ -10,6 +10,6 @@
 // Created On       : Tue Jan 17 12:27:26 2017
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Dec  1 17:52:57 2019
-// Update Count     : 45
+// Last Modified On : Tue Dec  3 21:46:54 2019
+// Update Count     : 49
 //
 
@@ -27,4 +27,5 @@
 #include <unistd.h>
 #include <limits.h>										// PTHREAD_STACK_MIN
+#include <sys/mman.h>									// mprotect
 }
 
@@ -281,10 +282,8 @@
 
 		thread_desc * readyThread = 0p;
-		for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ )
-		{
+		for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) {
 			readyThread = nextThread( this->cltr );
 
-			if(readyThread)
-			{
+			if(readyThread) {
 				verify( ! kernelTLS.preemption_state.enabled );
 
@@ -297,7 +296,5 @@
 
 				spin_count = 0;
-			}
-			else
-			{
+			} else {
 				// spin(this, &spin_count);
 				halt(this);
@@ -445,5 +442,5 @@
 
 static void Abort( int ret, const char * func ) {
-	if ( ret ) {
+	if ( ret ) {										// pthread routines return errno values
 		abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) );
 	} // if
@@ -455,14 +452,19 @@
 	Abort( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
 
+	size_t stacksize;
+	 // default stack size, normally defined by shell limit
+	Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
+	assert( stacksize >= PTHREAD_STACK_MIN );
+
 #ifdef __CFA_DEBUG__
-	size_t guardsize;
-	Abort( pthread_attr_getguardsize( &attr, &guardsize ), "pthread_attr_getguardsize" );
-	Abort( pthread_attr_setguardsize( &attr, guardsize ), "pthread_attr_setguardsize" );
+	void * stack = memalign( __page_size, stacksize + __page_size );
+	// pthread has no mechanism to create the guard page in user supplied stack.
+	if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
+		abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
+	} // if
+#else
+	void * stack = malloc( stacksize );
 #endif
 
-	size_t stacksize;
-	Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" ); // default stack size, normally defined by shell limit
-	assert( stacksize >= PTHREAD_STACK_MIN );
-	void * stack = malloc( stacksize );
 	Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" ); 
 
