#include <kern/kern_cdata.h>
#include <mach/mach_vm.h>
#include <kern/exc_guard.h>
+#include <os/log.h>
#if CONFIG_MACF
#include <security/mac_mach_internal.h>
return gate.corpses;
}
+extern char *proc_best_name(struct proc *);
+extern int proc_pid(struct proc *);
+
/*
* Routine: task_crashinfo_get_ref()
* Grab a slot at creating a corpse.
task_crashinfo_get_ref(corpse_flags_t kcd_u_flags)
{
union corpse_creation_gate oldgate, newgate;
+ struct proc *p = (void *)current_proc();
assert(kcd_u_flags & CORPSE_CRASHINFO_HAS_REF);
newgate = oldgate;
if (kcd_u_flags & CORPSE_CRASHINFO_USER_FAULT) {
if (newgate.user_faults++ >= TOTAL_USER_FAULTS_ALLOWED) {
+ os_log(OS_LOG_DEFAULT, "%s[%d] Corpse failure, too many faults %d\n",
+ proc_best_name(p), proc_pid(p), newgate.user_faults);
return KERN_RESOURCE_SHORTAGE;
}
}
if (newgate.corpses++ >= TOTAL_CORPSES_ALLOWED) {
+ os_log(OS_LOG_DEFAULT, "%s[%d] Corpse failure, too many %d\n",
+ proc_best_name(p), proc_pid(p), newgate.corpses);
return KERN_RESOURCE_SHORTAGE;
}
if (atomic_compare_exchange_strong_explicit(&inflight_corpses,
&oldgate.value, newgate.value, memory_order_relaxed,
memory_order_relaxed)) {
+ os_log(OS_LOG_DEFAULT, "%s[%d] Corpse allowed %d of %d\n",
+ proc_best_name(p), proc_pid(p), newgate.corpses, TOTAL_CORPSES_ALLOWED);
return KERN_SUCCESS;
}
}
if (atomic_compare_exchange_strong_explicit(&inflight_corpses,
&oldgate.value, newgate.value, memory_order_relaxed,
memory_order_relaxed)) {
+ os_log(OS_LOG_DEFAULT, "Corpse released, count at %d\n", newgate.corpses);
return KERN_SUCCESS;
}
}
/* Terminate all the other threads in the task. */
queue_iterate(&new_task->threads, thread_next, thread_t, task_threads)
{
- thread_terminate_internal(thread_next);
+ thread_terminate_internal(thread_next, TH_TERMINATE_OPTION_NONE);
}
/* wait for all the threads in the task to terminate */
task_wait_till_threads_terminate_locked(new_task);