CI run 29647981277 exposed a Linux unit-shard UAF in finishInspectorClient while the module-worker inspector target was closing.
Root cause:
runtime_detachedis published before the final event-queue pushes/close, so the owner can wake and destroyInspectorClient.eventswhile the worker still uses it.- queued inspector commands retain raw
InspectorClientpointers without ownership, so commands already behind a terminal detach/failure can outlive the owner reference.
Acceptance:
- Publish runtime detach only after every worker-side event access is complete, with a final wake.
- Give every queued command explicit client ownership and release it on every drain/error path.
- Keep owner-thread queue destruction after runtime detach without leaks or deadlock.
- Re-run the exact failing module-worker inspector test repeatedly and under TSan.
- Confirm the normal/TSan CI shards are green.