Skip to content

Use checked arithmetic when decoding row-encoding options metadata - #11395

Merged
robert3005 merged 1 commit into
vortex-data:developfrom
ump45nose:fix/11393-row-options-checked-len
Nov 12, 2026
Merged

robert3005 merged 1 commit into
vortex-data:developfrom
ump45nose:fix/11393-row-options-checked-len

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

Summary

deserialize_row_encoding_options reads a u32 field count from the metadata and computed the expected length as 4 + 2 * n before validating the input length. On 32-bit targets a count like 0x8000_0000 overflows usize there, which panics in checked builds instead of returning an error.

Changes

  • Compute the expected metadata length with checked_mul / checked_add and bail with an error if it overflows, so oversized counts are rejected the same way as other malformed metadata.
  • Add unit tests in vortex-row/src/options.rs for a serialize/deserialize roundtrip, for huge declared field counts (0x8000_0000 and u32::MAX), and for truncated metadata. On a 64-bit host the huge counts are rejected by the length check; the overflow itself only applies to 32-bit targets.

Tested with cargo test -p vortex-row and cargo clippy -p vortex-row --all-targets -- -D warnings.

AI assistance: this change was prepared with help from an AI coding assistant (agentic), and reviewed and submitted by me.

The declared field count in RowEncodingOptions metadata is read from the
input, so computing the expected length as 4 + 2 * n could overflow usize
on 32-bit targets before the length check. Use checked arithmetic and
return an error instead.

Fixes vortex-data#11393

Signed-off-by: Vincent <1729065730@qq.com>
@robert3005 robert3005 added the changelog/fix A bug fix label Nov 12, 2026
@codspeed

codspeed Bot commented Nov 12, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 16.19%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚡ 3 improved benchmarks
✅ 1918 untouched benchmarks
⏩ 50 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation bench_compare_varbin[(50000, 2)] 162.9 µs 134.2 µs +21.4%
⚡ CPU Simulation bench_compare_sliced_dict_varbinview[(1000, 10000)] 92.3 µs 80.9 µs +14.09%
⚡ CPU Simulation bench_compare_sliced_dict_varbinview[(9999, 10000)] 234 µs 206.6 µs +13.26%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ump45nose:fix/11393-row-options-checked-len (8f50425) with develop (bc3d422)

Open in CodSpeed

Footnotes

  1. 50 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@robert3005
robert3005 merged commit ed564f6 into vortex-data:develop Nov 12, 2026
99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants