Apple & iOS
AuraScore 83/100

Swift Concurrency Crash and Thread Safety Audit

Investigate complex Swift concurrency bugs, race conditions, and actor isolation crashes into a structured technical report.

Use this template when troubleshooting persistent EXC_BAD_ACCESS errors, actor reentrancy anomalies, or thread sanitizer failures in iOS apps. It guides the investigation through root-cause analysis to architectural remediation.

Template

Role: Senior iOS Concurrency Specialist and Runtime Systems Debugger

Context

  • Target Application: {{app_name}}
  • Swift Language Version: {{swift_version}}
  • Concurrency Architecture: {{concurrency_model}}
  • Faulting Subsystem: {{affected_subsystem}}
  • Crash Stack Trace or Log: {{crash_stack_trace}}
  • Reproduction Frequency and Environment: {{reproduction_rate}}

Task

Produce an exhaustive technical diagnostic report that dissects the concurrency failure in {{app_name}}, identifies the exact race condition or actor violation, and provides concrete, thread-safe refactoring solutions.

Method

  1. Analyze the stack trace provided in {{crash_stack_trace}} alongside {{concurrency_model}} to identify thread transitions, lock contentions, or unsafe memory dereferences.
  2. Trace data flow across isolation boundaries within {{affected_subsystem}} to uncover non-Sendable type leaks.
  3. Evaluate actor reentrancy risks and potential deadlocks caused by unstructured Task hierarchies in {{swift_version}}.
  4. Reconstruct the failure timeline using {{reproduction_rate}} to isolate critical timing windows.
  5. Design an immutable or actor-isolated architectural fix that preserves UI responsiveness on the main dispatch queue.
  6. Formulate precise unit and Thread Sanitizer (TSan) test scenarios to prevent regression.
  7. Provide refactored Swift code samples demonstrating before-and-after thread safety guarantees.

Constraints

  • MUST cite specific Swift concurrency rules and compiler guarantees relevant to {{swift_version}}.
  • MUST NOT recommend deprecated GCD workarounds (such as DispatchQueue.sync on main thread) to resolve actor issues.
  • Solutions MUST preserve UI responsiveness and adhere to strict concurrency checking.
  • Refactored code examples must be compile-ready without placeholder symbols.

Output format

Generate a structured engineering report containing:

  1. Executive Incident Summary (max 150 words)
  2. Root Cause & Memory Timeline Analysis
  3. Concurrency Safety Breakdown (Isolation, Sendable, & Reentrancy)
  4. Architectural Remediation (with Before/After Code Snippets)
  5. Verification & TSan Test Plan

Self-review

  • Confirm every variable in {{app_name}}, {{swift_version}}, and {{crash_stack_trace}} is addressed.
  • Verify that proposed code eliminates data races without introducing deadlocks.
  • Check that the report strictly separates diagnostic findings from preventative recommendations.
AuraScore breakdown
83/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering12/12 · Strong

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency7/10 · Adequate

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-apple
software-engineering-debugging
swift
concurrency
debugging