poteto-mode orch store: stale-lock takeover can delete a live lock and admit two writers

Đang mở
#1,055 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
tooling

Hướng nghiên cứu

Start in scripts/orch/store.ts at acquireLock around :385-430, especially the EEXIST path and the unconditional unlink in takeOver at :394; also inspect --force handling. Reproduce the interleaving with the in-memory filesystem approach described, then design recovery serialization and a per-acquisition token checked by release and takeover. Done means the two-acquirer/one-stale-holder schedule admits at most one writer and the regression test asserts that.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Found against pstack 0.15.34 at cursor/plugins 519d36aa98955bf680db01bcde5fdfba686dc901 (harness/pstack/claude-code/skills/poteto-mode/). Line numbers refer to that commit.

scripts/orch/store.ts (acquireLock, around :385-430) recovers a stale lock like this:

  1. open(path, "wx") fails with EEXIST.
  2. It reads the holder PID, and holderIsDead(holder) is true.
  3. takeOver() calls unlink(path) unconditionally (:394), then create() again.

Between steps 2 and 3, another process can take over the same stale lock and create its own lock file. The slower
process then unlinks that new, live lock and creates its own. Both believe they hold the lock. The same applies to
--force (options.force). Every store write is a whole-file read-modify-write (unit updates, ledger records, gates,
standing orders), so two writers lose updates: units or verification records disappear.

Repro (executed in a no-write harness, using the transpiled acquireLock body over an in-memory filesystem):

A and B both fail create() with EEXIST and read the same dead holder PID.
A: unlink, create -> A holds the lock.
B resumes: unlink (deletes A's live lock), create -> B holds the lock too.

Suggested fix:

  • Serialize recovery with a separate exclusive mechanism, such as an OS advisory lock (flock) or a separate
    wx-created recovery lock that is itself removed only by its creator.
  • Write a unique token with each acquisition (pid plus random nonce plus time), and have release and takeover check
    that token instead of only the PID.
  • Rereading the holder just before the unlink narrows the window but doesn't close it.
  • Add a concurrency regression test for the schedule above: two acquirers, one stale holder, interleaved
    read/unlink/create. Assert that at most one acquirer succeeds.
Ngôn ngữ chính
TypeScript
Star
18.2k
Fork
2k
Merge trung bình
3 giờ 56 phút
Pull request đã merge (30 ngày)
96

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cursor/plugins

Tất cả issue của cursor/plugins

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.