开发与测试
concurrency-race-detector
Identifies race conditions, mutex contention, unsafe shared state, and deadlocks in concurrent and async code.
codebygarv · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add codebygarv/Ai-skills --skill concurrency-race-detector技能说明
name: concurrency-race-detector description: Identifies race conditions, mutex contention, unsafe shared state, and deadlocks in concurrent and async code.
Purpose
Detect and resolve concurrency vulnerabilities, shared-state data races, asynchronous interleaving bugs, lock inversion deadlocks, and missed synchronization in multi-threaded or async event-loop environments.
When to Use
- When debugging intermittent bugs that only reproduce under high concurrency or specific network latency.
- Reviewing shared in-memory caches, counter updates, or distributed lock implementations.
- Writing Go goroutines, Rust async/tokio, Java threads, or Node.js async operations with shared references.
What to Analyze
- Shared Mutable State: Find variables, collections, or files accessed concurrently without atomics or locks.
- Check-Then-Act Flaws (TOCTOU): Inspect code where state is checked, and acted upon in separate non-atomic operations.
- Lock Ordering & Deadlocks: Trace acquisition order of multiple mutexes across threads.
- Node.js Event Loop Interleaving: Identify
awaitcalls between reading and writing shared object properties. - Database Transaction Isolation: Check for lost updates or phantom reads under
READ COMMITTEDisolation.
Output Format
- Vulnerability Breakdown: Exact line references and the failing execution trace interleaving.
- Reproduction Scenario: Sequence diagram or step-by-step thread execution trace showing the race.
- Remediation Code: Thread-safe refactoring using atomic primitives, locks, mutexes, or immutability.
- Verification Strategy: Stress test script / race detector command (e.g.
go test -race).
Avoid
- Assuming single-threaded JavaScript runtimes are immune to async race conditions across
awaitboundaries. - Suggesting coarse global locks that kill multi-core throughput.