Repository navigation
Conversation
The wasm SIMD byte-range test used signed `wasm_i8x16_ge/le`, so a range crossing 0x7f/0x80 (e.g. [0x0e, 0xff]) matched no bytes. A self-looping table-lookup node then advanced zero bytes and took its `otherwise` edge, which can spin when that edge leads back to the node. Use `wasm_u8x16_ge/le`, matching the NEON and SSE paths.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: the wasm SIMD byte-range test is emitted with signed ops (
wasm_i8x16_ge/le). For a range that crosses the 0x7f/0x80 boundary — e.g.[0x0e, 0xff]—wasm_i8x16_le(input, 0xff)compares against0xffas signed-1, so every byte with the high bit clear fails the test. In a self-looping table-lookup node the vector block then advances zero bytes and falls through to the node'sotherwiseedge; whereotherwiseroutes back to the same node (as llhttp'sheader_value_relaxedstate does in 9.4.x), the parser spins without consuming input.After: range comparisons use
wasm_u8x16_ge/le. Bytes are unsigned, so crossing ranges match correctly and the vector loop advances. NEON (vcgeq_u8/vcleq_u8) and SSE (_SIDD_UBYTE_OPS) were already unsigned; this aligns wasm with them.Repro: build llhttp 9.4.3 to wasm with
-msimd128, enablellhttp_set_lenient_header_value_relaxed, and parse a ≥16-byte relaxed header value — the SIMD build hangs while the scalar build returnsHPE_OK. An exhaustive check over all ranges × all bytes shows 2,113,536 mismatches with the signed ops and 0 with unsigned.How: two-token change in
buildWASM(table-lookup.ts). Added a compiler test with a[0x0e, 0xff]self-loop that fails on the wasm build before this change and passes after. The wasm variant is only built whenWASMis set in the fixture env, so the new test is exercised withWASM=clang WASM_CFLAGS="--target=wasm32-unknown-wasi" npm run mocha.