=== modified file 'sql/sql_class.cc'
--- sql/sql_class.cc	2012-12-17 09:56:26 +0000
+++ sql/sql_class.cc	2012-12-26 00:54:19 +0000
@@ -1260,6 +1260,7 @@ void THD::init(void)
   debug_sync_init_thread(this);
 #endif /* defined(ENABLED_DEBUG_SYNC) */
   apc_target.init(&LOCK_thd_data);
+  //fprintf(stderr, "THD::init %p\n", this);
 }
 
  
@@ -3861,12 +3862,16 @@ void THD::restore_backup_open_tables_sta
 
 extern "C" int thd_killed(const MYSQL_THD thd)
 {
+  //fprintf(stderr, "thd_killed: %p %p\n", thd, current_thd);
   if (!thd)
     thd= current_thd;
-
-  Apc_target *apc_target= (Apc_target*)&thd->apc_target;
-  if (apc_target->have_apc_requests())
-      apc_target->process_apc_requests(); 
+  
+  if (current_thd)
+  {
+    Apc_target *apc_target= (Apc_target*)&thd->apc_target;
+    if (apc_target->have_apc_requests())
+        apc_target->process_apc_requests(); 
+  }
 
   if (!(thd->killed & KILL_HARD_BIT))
     return 0;

