aw-query/aw-transform: deep-nesting stack overflow, backslash strings, silent lexer truncation and 6 more (bug-hunt follow-ups)

オープン
#882 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@TimeToBuildBob がすでに取り組んでいます。

2026年11月24日 から。

  • #899 @TimeToBuildBob による — オープン
  • #900 @TimeToBuildBob による — オープン
  • #901 @TimeToBuildBob による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
backend

調査の方向性

Nine separate follow-ups, not one task: pick a single numbered item and leave the rest. Items 1-3 live in the aw-query lexer and parser — the reproducer queries are in the issue text, and tests/regex_fuzz.rs already records the backslash gap; item 5 points at the TODO in interpret.rs. For the transforms (8-9), period_union, merge_events_by_keys, flood and filter_period_intersect in aw-transform are where durations are summed, and heartbeat already has an overflow-refusal test to copy. Done means the named reproducer no longer fails and cargo test passes for the touched crate.

索引モデルが issue の本文から書いたものです。

説明

Follow-ups from a verified bug hunt over aw-query and aw-transform at ea6f09c. The fixed items are in #880 (transform) and #881 (query panics). These remain, best first. Each one marked reproduced was run against aw_query::query on master.

Query language

  1. Deep nesting aborts the server (reproduced). return 1+1+…+1; with 100k terms (about 200 KB) overflows a 2 MiB thread stack and aborts the whole process (fatal runtime error: stack overflow, SIGABRT). catch_unwind can't catch that. The parser builds the left-recursive binop tree on its heap stack, and then interpret_expr, the generated Drop for Box<Expr>, and serde all recurse once per level. A parse-time depth limit is the robust fix, because an iterative evaluator wouldn't cover the recursive drop. Reach: any local process, since the request needs Content-Type: application/json, which blocks cross-origin pages.
  2. A string ending in a backslash breaks the whole query (reproduced). return ["a\\", "b"]; gives ParsingError. The string token regex "([^"]|(\\"))*" has no \\ escape, so \" keeps the string open. aw-webui collapses \\ to \ in the categories JSON (queries.ts), so a category regex ending in an escaped backslash (for example a Windows path like C:\\Users\\) makes every categorised view fail. tests/regex_fuzz.rs notes that \\ isn't handled. A fix has to stay compatible with that aw-webui workaround.
  3. An unlexable character silently ends the program (reproduced). return 1;\n@ return 2; returns 1 with no error. plex returns None when no rule matches, and Lexer::next treats that as end of input. A non-breaking space or a smart quote pasted between statements does the same, and silently drops the rest of the query.
  4. All binary operators share one precedence level (reproduced; design question). return 1 + 2 * 3; gives 9, and return 2 == 1 + 1; is an InvalidType error. Every binop production is binop OP func. If flat left-to-right is intended it should be documented; otherwise *///% should bind tighter than +/-, and those tighter than ==.
  5. return doesn't exit (reproduced; possibly intended). if True { return 1; } return 2; gives 2. return only assigns RETURN (there's a TODO in interpret.rs).
  6. Self-concatenation has no size bound (traced). Statements like a = a + a; double a string or list each time. About 30 of them reach gigabytes, and the 300 s budget is only checked between statements, so a sub-1 KB query can OOM the server.
  7. TIMEINTERVAL is a reassignable variable (traced). A query that overwrites it reads outside the requested period, but its result is cached and invalidated under the requested period. That can serve stale data to clients that do this. aw-webui doesn't.

Transforms (traced, not run)

  1. Merged durations can exceed the serializable range. period_union, merge_events_by_keys and flood add durations with +=, so two valid ~200-year events can sum past num_nanoseconds(). The later .unwrap() in aw-models (calculate_endtime, get_nanos) then panics the request. heartbeat already refuses this (test_heartbeat_refuses_merge_that_overflows_duration). This needs events over 146 years long, which only an import can create.
  2. filter_period_intersect passes negative-duration events through. {ts 5s, dur -2s} against [0s, 10s) is returned unchanged by the "a within b" branch. flood drops these deliberately, so queries that don't flood first can lose time. The import endpoint doesn't reject negative durations.
主要言語
Rust
スター
322
フォーク
107
平均マージ
2日 16時間
マージ済み PR(30日)
25

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ActivityWatch/aw-server-rust のほかの issue

ActivityWatch/aw-server-rust の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。