Skip to content

vertexcodec: Fix Wasm SIMD rotate32 to use logical instead of arithmetic shift#1043

Merged
zeux merged 3 commits intomasterfrom
wasm-xor
Apr 15, 2026
Merged

vertexcodec: Fix Wasm SIMD rotate32 to use logical instead of arithmetic shift#1043
zeux merged 3 commits intomasterfrom
wasm-xor

Conversation

@zeux
Copy link
Copy Markdown
Owner

@zeux zeux commented Apr 15, 2026

i32x4_shr performs an arithmetic shift which extends the sign bit into
the portion that is then or'd with the rest of the rotate; if the
encoded high bit is 1, the output may be decoded incorrectly.

Note that this only affects Wasm and only affects cases where encoded
data uses version 1 and level 3, as xor isn't used in other cases. This
also appears to be difficult to hit on real content; the added test is synthetic.

zeux added 3 commits April 14, 2026 18:57
…tic shift

i32x4_shr performs an arithmetic shift which extends the sign bit into
the portion that is then or'd with the rest of the rotate; if the
encoded high bit is 1, the output may be decoded incorrectly.
This incorporates the fix to Wasm32 rotate decoding.
Previously our tests did not include cases where the encoded values have
most significant bit of 1; this masked the bug in Wasm32 rotate decoding
which could happen in rare circumstances.

Note that this only affects Wasm and only affects cases where encoded
data uses version 1 and level 3, as xor isn't used in other cases.
@zeux
Copy link
Copy Markdown
Owner Author

zeux commented Apr 15, 2026

This was introduced in v0.23, a little over a year ago, and appears to be difficult to hit naturally. The issue was discovered using LLM driven static analysis - not on real data. Unfortunately, it was right after the 1.1 release, so the fix obviously didn't make it. The scope here is limited but the timeline until 1.2 is quite long (many months).

I'm considering a patch (1.1.1) release that, to reduce the release burden and minimize churn, would be scoped to meshoptimizer NPM package. This would be similar to 1.0.1 release that was also NPM only, although that one had no C++ changes.

@zeux zeux merged commit 32b15e0 into master Apr 15, 2026
26 checks passed
@zeux zeux deleted the wasm-xor branch April 15, 2026 15:23
@zeux
Copy link
Copy Markdown
Owner Author

zeux commented Apr 15, 2026

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