Increment suspend count before attempting attach in suspend_for_ptrace.
diff --git a/server/ptrace.c b/server/ptrace.c
index 0346e72..938d817 100644
--- a/server/ptrace.c
+++ b/server/ptrace.c
@@ -166,12 +166,12 @@
suspend_thread( thread, 0 );
return 1;
}
- if (attach_thread( thread ))
- {
- /* the attach will have suspended it */
- thread->suspend++;
- return 1;
- }
+ /* can't stop a thread while initialisation is in progress */
+ if (!thread->unix_pid || thread->process->init_event) goto error;
+ thread->suspend++;
+ if (attach_thread( thread )) return 1;
+ thread->suspend--;
+ error:
set_error( STATUS_ACCESS_DENIED );
return 0;
}