Skip to content

fix(vag_vehicle): unzip without overflowing gopher-lua's value stack - #142

Merged
frahlg merged 1 commit into
mainfrom
fix/vag-vehicle-gopher-lua
Sep 26, 2026
Merged

frahlg merged 1 commit into
mainfrom
fix/vag-vehicle-gopher-lua

Conversation

@frahlg

@frahlg frahlg commented Sep 26, 2026

Copy link
Copy Markdown
Member

Follow-up to #141. vag_vehicle 0.1.0 fails on a real FTW box for any dataset larger than a few kB. This fixes it as 0.1.1.

What was wrong

FTW runs its Lua drivers in gopher-lua. Its table.concat puts every item of the range on a value stack of about 5,000 slots, so a long range fails with registry overflow. The unzip joined its whole output in one call, 98,346 items for a 360 kB file. The first version from the Cursor agent did the same with table.concat(out).

The repository's tests run C Lua 5.5, which has no such limit, so they passed.

Fix

  • Join at most 256 items per table.concat call, in a small tree.
  • The VAG harness now refuses table.concat ranges of 2,000 items or more, like gopher-lua would. A new 360 kB fixture makes the unzip flush. With the old join put back, the test fails on a 98,346-item concat.
  • The dataset cap drops from 4 MiB to 2 MiB (see below).

Evidence from FTW's own host

I loaded the driver with FTW's NewLuaDriver (real gopher-lua, json_decode, emit and telemetry store), and stubbed only host.http_get:

Dataset Poll SoC in Core
1 kB (stored, deflated, streamed zip) under 2 ms 0.63
100 kB JSON 55 ms read
1 MB JSON 0.6 s read
5 MB JSON (over the cap) refused —

That was an Apple M-series core. A poll has 10 seconds and a Raspberry Pi is several times slower, hence the 2 MiB cap. The size of a real All Data file is still unknown.

Checks

  • make test-driver ID=vag_vehicle: 36 passed, 16 skipped
  • make check: 4731 passed, 913 skipped

Other drivers may carry the same C Lua versus gopher-lua gap; that is a separate question for the harness as a whole.

🤖 Generated with Claude Code

A dataset of more than a few kB failed on a box with "registry
overflow". FTW runs gopher-lua, whose table.concat puts every item of
the range on a value stack of about 5,000 slots, and the unzip joined
its whole output in one call. It now joins at most 256 items per call.

The tests run C Lua, which has no such limit, so they passed. The VAG
harness now refuses table.concat ranges of 2,000 items or more, and a
360 kB fixture makes the unzip flush. Put back the old join and the
test fails on a 98,346-item concat.

Run in FTW's own host (NewLuaDriver, real json_decode and telemetry
store, HTTP stubbed), 100 kB of JSON took 55 ms per poll and 1 MB took
0.6 s on an Apple M-series core. A poll has 10 seconds and a Raspberry
Pi is several times slower, so the dataset cap drops from 4 MiB to
2 MiB. Version 0.1.1, since 0.1.0 is published.

Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-26T11:22:14.794058Z 19bd6a5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@frahlg
frahlg merged commit eeb3e06 into main Sep 26, 2026
5 checks passed
@frahlg
frahlg deleted the fix/vag-vehicle-gopher-lua branch September 26, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant