跳到正文
cccskills
Microsoft 官方免费在 GitHub 公开

windbg-user-mutex-held-across-co-await

Use when app, service, or user-mode driver C++ coroutine code holds a thread-affine lock across suspension and later hangs or fails. Not for all coroutine crashes or choosing lock performance.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md4.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Mutex Held Across co_await

Load windbg-diagnostic-method first if it is not already loaded in this conversation, and apply it throughout for evidence ranking, hypothesis testing, confidence calibration, independent review, and report validation. This skill adds the bug-family-specific commands and evidence requirements.

Detection

This pattern can occur in native application, service, or user-mode driver code, including UMDF components that use C++ coroutines. Look for a lock acquired before co_await and released after resumption or coroutine destruction. Mutex ownership belongs to the acquiring thread, not the coroutine frame. A resumption on another thread can violate that contract. Even same-thread resumption can create reentrancy or progress problems when the awaited operation needs a lock the coroutine still holds.

Workflow

  1. Identify the exact lock primitive and acquisition/release scope in source. Audit every suspension point while the RAII guard or ownership is alive.
  2. Establish the acquire and resume threads using trace/source evidence. Standard mutexes and SRW locks do not provide a universally queryable owner field; do not fabricate an owning TID from undocumented layouts.
  3. Verify the awaiter's resumption contract. C++/WinRT can preserve apartment context for particular awaitables; resume_background intentionally switches. Do not assume every WinRT awaitable always resumes on a worker or always on the originating thread.
  4. Distinguish wrong-thread release, a dependency cycle, state changed during suspension, lifetime failure, and unrelated memory corruption.
  5. Move the thread-affine lock into synchronous scopes. Revalidate relevant state after the await rather than treating the pre-await snapshot as current.

If the symptom is general blocking use windbg-user-wait-chain-analysis. For damaged heap objects use windbg-user-heap-corruption-investigation. If a recording is available, windbg-user-ttd-reverse-debugging-triage can help establish the ownership timeline.

Fix pattern

Conceptual sequence, not a promise about any particular scheduler:

under lock:
    take a snapshot and its generation
release lock
await work using that snapshot
under lock on the resumed thread:
    revalidate generation, lifetime, and assumptions
    apply result or explicitly handle a stale/cancelled operation
release lock

Use RAII for each synchronous scope. If invariants cannot tolerate unlocking, redesign the operation or use a specifically designed asynchronous coordination primitive with cancellation/lifetime rules. Switching to a recursive mutex or shared_mutex does not make a thread-affine lock coroutine-safe.

Do not recommend a blanket mutex-type replacement. Shared locking is a separate design decision; changing the primitive does not repair suspension ownership. Keep the object and any captured interfaces alive across asynchronous work.

Validation

  • No thread-affine lock ownership survives a suspension in the corrected path.
  • Each awaiter's thread/apartment contract is understood.
  • State invariants are revalidated after suspension.
  • Cancellation, concurrent mutation, shutdown, and failed awaited work are tested.
  • The remedy removes the demonstrated cause, not just an observed exception.

References

Feedback

Follow FEEDBACK.md and report reviewed, sanitized feedback to WinDbg-Feedback. Include windbg-user-mutex-held-across-co-await and the package version from plugin.json; no automatic source, dump, or transcript upload.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

windbg-diagnostic-method

Microsoft 官方免费

Use with every WinDbg plugin investigation to apply evidence-first reasoning, confidence calibration, contrarian review, structured reporting, and deterministic validation. Not a bug-family-specific triage skill.

中文简介正在准备中。当前显示原文说明。

microsoft/win-dev-skills4762026年10月20日 更新

windbg-kernel-bugcheck-triage

Microsoft 官方免费

Use when a kernel dump reports a Windows bugcheck; decode parameters and recover exception or trap context before investigating your driver. Not for user-mode process crashes or blaming a module from its name alone.

中文简介正在准备中。当前显示原文说明。

microsoft/win-dev-skills4762026年10月20日 更新

Use when kernel evidence shows stalled I/O, a power IRP, or completion/cancellation misuse; inspect request state and driver ownership. Not for interpreting an empty IRP search in a limited dump as proof of healthy I/O.

中文简介正在准备中。当前显示原文说明。

microsoft/win-dev-skills4762026年10月20日 更新

Use when kernel threads block on driver synchronization or Verifier reports a lock-order violation; build an owner/waiter graph. Not for treating every watchdog stop as a deadlock or listing every lock type with !locks.

中文简介正在准备中。当前显示原文说明。

microsoft/win-dev-skills4762026年10月20日 更新

windbg-kernel-verifier-triage

Microsoft 官方免费

Use when a kernel dump contains Driver Verifier violations; inspect flags, bugcheck subcodes, and available I/O shadow state. Not for Application Verifier user-mode stops or inferring a violation from enabled flags alone.

中文简介正在准备中。当前显示原文说明。

microsoft/win-dev-skills4762026年10月20日 更新

windbg-user-exception-triage

Microsoft 官方免费

Use when a native C/C++ app, service, or user-mode driver host (including UMDF) crashes with a structured exception in a dump or WinDbg session, including native faults inside managed processes. Not for managed .NET exceptions, WinUI/XAML app errors, or kernel bugchecks.

中文简介正在准备中。当前显示原文说明。

microsoft/win-dev-skills4762026年10月20日 更新

查看 microsoft 的全部技能

报告此技能的问题