Index: cpukit/posix/include/rtems/posix/posixapi.h
===================================================================
--- cpukit/posix/include/rtems/posix/posixapi.h	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/posix/include/rtems/posix/posixapi.h	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -90,5 +90,5 @@
  * identifier.
  *
- * Generates a function body to get the object for the specified indentifier.
+ * Generates a function body to get the object for the specified identifier.
  * Performs automatic initialization if requested and necessary.  This is an
  * ugly macro, since C lacks support for templates.
@@ -106,4 +106,5 @@
     return NULL; \
   } \
+  _Thread_queue_Initialize( queue_context ); \
   the_object = _Objects_Get( \
     (Objects_Id) *id, \
Index: cpukit/posix/src/mutexsetprioceiling.c
===================================================================
--- cpukit/posix/src/mutexsetprioceiling.c	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/posix/src/mutexsetprioceiling.c	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -68,5 +68,4 @@
       Per_CPU_Control      *cpu_self;
 
-      _Thread_queue_Context_clear_priority_updates( &queue_context );
       _CORE_ceiling_mutex_Set_priority(
         &the_mutex->Mutex,
Index: cpukit/posix/src/pthread.c
===================================================================
--- cpukit/posix/src/pthread.c	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/posix/src/pthread.c	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -92,6 +92,6 @@
   the_thread = api->thread;
 
+  _Thread_Wait_acquire( the_thread, &queue_context );
   _Thread_queue_Context_clear_priority_updates( &queue_context );
-  _Thread_Wait_acquire( the_thread, &queue_context );
 
   if ( _Priority_Node_is_active( &api->Sporadic.Low_priority ) ) {
@@ -123,6 +123,6 @@
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
+  _Thread_Wait_acquire( the_thread, &queue_context );
   _Thread_queue_Context_clear_priority_updates( &queue_context );
-  _Thread_Wait_acquire( the_thread, &queue_context );
 
   /*
Index: cpukit/posix/src/pthreadgetschedparam.c
===================================================================
--- cpukit/posix/src/pthreadgetschedparam.c	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/posix/src/pthreadgetschedparam.c	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -54,4 +54,5 @@
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
 
+  _Thread_queue_Context_initialize( &queue_context );
   _Thread_Wait_acquire_critical( the_thread, &queue_context );
 
Index: cpukit/score/include/rtems/score/coremuteximpl.h
===================================================================
--- cpukit/score/include/rtems/score/coremuteximpl.h	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/score/include/rtems/score/coremuteximpl.h	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -254,4 +254,5 @@
   if ( owner != NULL ) {
     _Thread_Wait_acquire( owner, queue_context );
+    _Thread_queue_Context_clear_priority_updates( queue_context );
     _Thread_Priority_change(
       owner,
Index: cpukit/score/include/rtems/score/threadqimpl.h
===================================================================
--- cpukit/score/include/rtems/score/threadqimpl.h	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/score/include/rtems/score/threadqimpl.h	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -88,7 +88,8 @@
 {
 #if defined(RTEMS_DEBUG)
-  memset( queue_context, 0, sizeof( *queue_context ) );
-  queue_context->enqueue_callout = _Thread_queue_Enqueue_do_nothing;
-  queue_context->deadlock_callout = _Thread_queue_Deadlock_fatal;
+  memset( queue_context, 0x7f, sizeof( *queue_context ) );
+#if defined(RTEMS_SMP)
+  _Chain_Initialize_node( &queue_context->Lock_context.Wait.Gate.Node );
+#endif
 #else
   (void) queue_context;
Index: cpukit/score/src/threadqenqueue.c
===================================================================
--- cpukit/score/src/threadqenqueue.c	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/score/src/threadqenqueue.c	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -421,4 +421,7 @@
   bool             success;
 
+  _Assert( (uint8_t) (uintptr_t) queue_context->enqueue_callout != 0x7f );
+  _Assert( (uint8_t) queue_context->timeout_discipline != 0x7f );
+
 #if defined(RTEMS_MULTIPROCESSING)
   if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet ) {
@@ -434,4 +437,5 @@
     _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
     _Thread_Wait_tranquilize( the_thread );
+    _Assert( (uint8_t) (uintptr_t) queue_context->deadlock_callout != 0x7f );
     ( *queue_context->deadlock_callout )( the_thread );
     return;
@@ -598,4 +602,5 @@
 )
 {
+  _Thread_queue_Context_clear_priority_updates( queue_context );
 #if defined(RTEMS_MULTIPROCESSING)
   _Thread_queue_MP_set_callout( the_thread, queue_context );
Index: cpukit/score/src/threadrestart.c
===================================================================
--- cpukit/score/src/threadrestart.c	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/score/src/threadrestart.c	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -58,6 +58,6 @@
   Thread_queue_Context queue_context;
 
+  _Thread_Wait_acquire( the_thread, &queue_context );
   _Thread_queue_Context_clear_priority_updates( &queue_context );
-  _Thread_Wait_acquire( the_thread, &queue_context );
 
   if ( priority < the_thread->Real_priority.priority ) {
Index: cpukit/score/src/threadtimeout.c
===================================================================
--- cpukit/score/src/threadtimeout.c	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ cpukit/score/src/threadtimeout.c	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -32,6 +32,6 @@
   the_thread = RTEMS_CONTAINER_OF( watchdog, Thread_Control, Timer.Watchdog );
 
+  _Thread_Wait_acquire( the_thread, &queue_context );
   _Thread_queue_Context_clear_priority_updates( &queue_context );
-  _Thread_Wait_acquire( the_thread, &queue_context );
 
   wait_flags = _Thread_Wait_flags_get( the_thread );
Index: testsuites/smptests/smpscheduler03/init.c
===================================================================
--- testsuites/smptests/smpscheduler03/init.c	(revision 9bf9068bb85367a23e285db416cc5fd62eb9dcc2)
+++ testsuites/smptests/smpscheduler03/init.c	(revision c09db57f37e02e8458e3bffce689774546845bef)
@@ -53,6 +53,6 @@
 )
 {
+  _Thread_Wait_acquire(thread, queue_context);
   _Thread_queue_Context_clear_priority_updates(queue_context);
-  _Thread_Wait_acquire(thread, queue_context);
   _Thread_Priority_change(
     thread,
