endpoints: a far-future event panics inside write_lock and poisons it, so every later write returns 500 until restart
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start in aw-server/src/endpoints/bucket.rs, where bucket_events_create and bucket_events_heartbeat call event_range() while holding write_lock. The overflow comes from Event::calculate_endtime() in aw-models/src/event.rs (line 43), which uses plain +. Reproduce with the Rocket local client using a far-future timestamp, then confirm the endpoint returns 400 and that later writes still succeed.
索引モデルが issue の本文から書いたものです。
説明
In aw-server/src/endpoints/bucket.rs, both bucket_events_create and bucket_events_heartbeat call event_range() while holding state.write_lock (write_lock.lock().unwrap(), lines ~179 and ~224). event_range() calls Event::calculate_endtime() (aw-models/src/event.rs:43), which adds the duration with a plain +. That addition panics when the result overflows chrono's range.
An event with a far-future timestamp and a valid duration (< 292 years) therefore panics inside the lock and poisons the Mutex. Every later lock().unwrap() then panics too, so all event writes return 500 until the server restarts: every watcher's heartbeats, event creates, single and bulk deletes. The datastore's own range check (event_nanos) would return a clean 400, but it runs after this point.
Repro (Rocket local client, upstream master ea6f09c):
POST /api/0/buckets/aw-watcher-web-firefox/heartbeat?pulsetime=1
{"timestamp":"+262000-01-01T00:00:00Z","duration":9e9,"data":{}}
-> 500 (panic: `DateTime + TimeDelta` overflowed)
POST /api/0/buckets/aw-watcher-web-firefox/heartbeat?pulsetime=1
{"timestamp":"2026-01-01T00:00:00Z","duration":0,"data":{}}
-> 500 (and the same for POST .../events and DELETE .../events/1)
POST .../events with the same far-future event gives the same result. A browser extension can send it too: the default CORS rule admits moz-extension:// origins for aw-watcher-web-* buckets. So one buggy client clock or extension takes data collection down for every watcher, silently, until restart.
Suggested fix
- Compute the range with
checked_add_signedand return 400 before taking the lock. Or validate the event's range first and take the lock after. - Stop the lock from failing permanently, e.g.
lock().unwrap_or_else(PoisonError::into_inner). It guards only ordering and protects no invariant that a panic could break.
Found in a verified review pass over the endpoints. No PR from me yet, because I already have three open from this pass (#869, #870, #871).
- 主要言語
- Rust
- スター
- 322
- フォーク
- 107
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 25
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ActivityWatch/aw-server-rust のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ActivityWatch/aw-server-rust#883 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
ActivityWatch/aw-server-rust#872 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ActivityWatch/aw-server-rust#798 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
query: categorize rules can pin unbounded memory in the regex cache and run past query_timeout対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
ActivityWatch/aw-server-rust#893 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
aw-client CLI ignores aw-client.toml host/port対応中かも @TimeToBuildBob が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
ActivityWatch/aw-server-rust#888 ·
メンテナーはふだん 1 日以内に返信
ActivityWatch/aw-server-rust の issue をすべて見る
似ている issue
-
area: cli good first issue type: feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
renaming a provider to a taken name fails with a raw sql error対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンarea:storage kind:bug priority:p3 ready
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug bugfix
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
storytold/photocraft#16975 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信