Repository navigation
Commit cc049cb
committed
fix(tokenizer): preserve is_escaped across the SIMD string scan in streaming mode
findStringEnd's SIMD scanners (AVX2/SSE2/NEON) take is_escaped by
reference and mutate it across the whole remaining buffer. When they do
not find the closing quote (consumed == remaining) the function falls
through to the scalar scan, which restarts from cursor_index -- but
is_escaped now held the SIMD end-of-buffer state, so re-running the escape
state machine flipped escape parity for a string crossing a streaming
buffer boundary. A string whose escaped quote (\") straddled a buffer
split then had the escaped quote treated as the terminator (wrong value /
ExpectedDelimiter).
Snapshot is_escaped before the SIMD scan and restore it before the scalar
fallback, so the fallback re-derives escape state from the correct
starting value. The snapshot/restore is compiled only when a SIMD path
exists (no unused-variable warning under -Werror), and the common path
(quote found -> early return) is unaffected. Rejected the originally
proposed "return NeedMoreData" fix, which would wrongly report a complete
string whose closing quote is the final buffer byte as incomplete.
Added a streaming regression test (verified: fails without the fix with
ExpectedDelimiter, passes with it). All 1648 unit-test assertions pass.1 parent cd5d7ee commit cc049cb
2 files changed
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1922 | 1922 | | |
1923 | 1923 | | |
1924 | 1924 | | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
1925 | 1933 | | |
1926 | 1934 | | |
1927 | 1935 | | |
| |||
1958 | 1966 | | |
1959 | 1967 | | |
1960 | 1968 | | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
1961 | 1975 | | |
1962 | 1976 | | |
1963 | 1977 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
137 | 173 | | |
138 | 174 | | |
139 | 175 | | |
| |||
0 commit comments