Repository navigation
fix(nft): address review findings before 0.10.0 - #80
Conversation
After threadGetArg() the guard re-tested threadHandle, so a NULL trackingInitHandle was dereferenced on the worker thread instead of logged. Reported by Qodo on #79. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
inflateAll() doubled its buffer with no upper bound, so a small archive with a huge expansion ratio could exhaust memory. Archives expanding past MARKER_DECOMPRESS_MAX_SIZE (128 MB, overridable at build time) are now rejected with -1. Also documents that decompressMarkers() should write to new paths: an existing marker set there is not preserved on failure. Reported by Qodo on #79. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Mod tracking path never supported adaptive templates: with the option on, trackingMod2d.c did not compile (mismatched signature, redeclared templ2). trackingMod.h now stops the build with an explicit #error, and trackingMod2d.c includes it so it uses the public declaration of ar2Tracking2dSubMod(). Reported by Qodo on #79. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Summary by QodoFix NFT tracking guards and bound .zft decompression
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo
1.
|
…g at the limit - the initial inflate buffer is now capped at MARKER_DECOMPRESS_MAX_SIZE, so limits below 4 MB are enforced - at the limit, zlib gets one spare output byte to finish the stream (final block, trailer); only output written there means the archive is too large - MARKER_DECOMPRESS_MAX_SIZE below 1 is a build error - new webarkit_nft_limit_test builds markerDecompress with a 1 MB limit: exactly at the limit, one byte over, and a limit below the initial buffer; run in CI Reported by Qodo on #80. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- emscripten/WebARKitLib: b5e4770 on WebARKitLib dev, which adds webarkit/WebARKitLib#80 (review fixes before 0.10.0: capped .zft decompression, trackingInitMain null check, explicit #error for AR2_CAPABLE_ADAPTIVE_TEMPLATE) - build/ and dist/ rebuilt with emsdk 4.0.17 (npm run build-docker, npm run build-ts); vitest 182 passed / 6 skipped, node 7/7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor: use the NFT helpers from WebARKitLib (#453) trackingMod, trackingMod2d, trackingSub, markerDecompress and NFTMarkerState moved to WebARKitLib (webarkit/WebARKitLib#75, #76) under WebARKit/WebARKitTrackers/WebARKitNFT. - tools/makem.js: take those sources from WebARKitLib and add its include directory - bindings (JS and Python): include <WebARKitTrackers/WebARKitNFT/...> - python-bindings/setup.py: new source and include paths - remove the copies from emscripten/ - bump the WebARKitLib submodule to feat/issue-75-webarkit-nft Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: report a failed .zft decompression through onError decompressMarkers() now returns -1 for a missing or malformed archive instead of exiting. The decompressZFT bindings returned 1 regardless, so loadZFT read temporary files that were never written and threw ENOENT before any callback ran. The bindings now return -1 on failure and loadZFT calls onError(prefix + ".zft"). Reported by Qodo on #687. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf: free the .zft archive from MEMFS once decompressed loadZFT kept /markerNFT_N.zft in the Emscripten filesystem for the whole session; the old C-side remove() built the name without the dot, so it never deleted it either. Suggested by Qodo on #687. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump WebARKitLib to dev and rebuild build/ and dist/ (#453) - emscripten/WebARKitLib: dfe8570 on WebARKitLib dev, the squash merge of webarkit/WebARKitLib#76 (same tree as the 480fdb9 used so far) - build/ and dist/ rebuilt with emsdk 4.0.17 (npm run build-docker, npm run build-ts) The earlier commits of this PR (0cff312, 3543c45, 00cf36e) changed C/C++, JS and TS sources without committing the rebuilt build/ and dist/; this commit brings them up to date with those changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump WebARKitLib to b2d6166 and rebuild build/ and dist/ - emscripten/WebARKitLib: b2d6166 on WebARKitLib dev, which adds webarkit/WebARKitLib#77 (#40: random template index computed in double precision in AR2/selectTemplate.c, fixing the -Wimplicit-const-int-float-conversion warning) - build/ and dist/ rebuilt with emsdk 4.0.17 (npm run build-docker, npm run build-ts); vitest 182 passed / 6 skipped, node 7/7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: bump WebARKitLib to b5e4770 and rebuild build/ and dist/ - emscripten/WebARKitLib: b5e4770 on WebARKitLib dev, which adds webarkit/WebARKitLib#80 (review fixes before 0.10.0: capped .zft decompression, trackingInitMain null check, explicit #error for AR2_CAPABLE_ADAPTIVE_TEMPLATE) - build/ and dist/ rebuilt with emsdk 4.0.17 (npm run build-docker, npm run build-ts); vitest 182 passed / 6 skipped, node 7/7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: pin WebARKitLib to the 0.10.0 release tag Move emscripten/WebARKitLib from b5e4770 (dev) to 4fd3034, the merge commit on master tagged 0.10.0, as the 0.9.0 pin pointed at master. Both commits have the same tree, so build/ and dist/ are unchanged and need no rebuild. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fixes three findings Qodo raised on the release PR #79, before tagging 0.10.0. All three are in code that came with #76.
Summary
a49cb73 –
trackingInitMainnull check: afterthreadGetArg()the guard re-testedthreadHandle, so a NULLtrackingInitHandlewas dereferenced on the worker thread.faa50a6 – cap the decompressed
.zftsize:inflateAll()grew its buffer without bound, so a small archive with a huge expansion ratio could exhaust memory. Archives expanding pastMARKER_DECOMPRESS_MAX_SIZE(128 MB, overridable with-D) now return-1. Real markers are a few MB.markerDecompress.hnow documents the return values, and thatoutTempshould name new files.dd3e7d8 –
AR2_CAPABLE_ADAPTIVE_TEMPLATE: the Mod tracking path never supported adaptive templates; with the option on,trackingMod2d.cdid not compile.trackingMod.hnow stops the build with an explicit#error, andtrackingMod2d.cincludes it. The option is0inconfig.h, so default builds are unaffected.7506d59 – limit edge cases (Qodo on this PR): the initial buffer is capped at the limit, so limits below 4 MB are enforced; at the limit zlib gets one spare byte to finish the stream, so an archive of exactly the limit is accepted. New
webarkit_nft_limit_test(markerDecompress built with a 1 MB limit), run in CI.Not changed, with reasons in the review threads on #79:
.zftpayloads are hex text, so an archive with a NUL is malformed and-1is correctTest plan
webarkit_nft_test13/13 (new:ArchiveExpandingPastTheLimitReturnsError),webarkit_test28/28webarkit_nft_limit_test3/3 (2 of them fail on dd3e7d8)AR2_CAPABLE_ADAPTIVE_TEMPLATE 1:trackingMod.candtrackingMod2d.cstop at the#errorWebARKitNFTbuilds with and without threadsexamples/DataNFT/zft/pinball.zftoutput still byte-identical to the original implementation🤖 Generated with Claude Code