ladybird/Libraries/LibJS/Rust
Andreas Kling 306060b448 LibJS: Add negative tests for the bytecode validator
Until now we had only confirmed that real, encoder-produced bytecode
passes the validator. That tells us we don't false-fail, but says
nothing about whether we actually catch a corrupted buffer.

This commit fills that gap with a set of Rust unit tests that
hand-craft minimal buffers and assert that each error category
triggers exactly when expected.

Coverage spans the three passes: unknown opcodes and truncated /
misaligned instructions for the structural walk, operand and label
out-of-range cases for the per-instruction checks, and basic block
/ exception handler / source map offsets for the structural
metadata pass. There's also a pair of cache-pointer tests that
pin the BeforeFixup vs AfterFixup behavior down: an out-of-range
cache index is rejected before fixup and silently skipped after,
because by then the slot holds a real pointer.

To make `cargo test` work for the staticlib crate without dragging
in the C++ allocator, RustAllocator falls back to the standard
system allocator under cfg(test). The test harness only ever runs
in cargo's test profile, so the production builds keep using the
ladybird-side allocator unchanged.
2026-05-03 08:43:19 +02:00
..
src LibJS: Add negative tests for the bytecode validator 2026-05-03 08:43:19 +02:00
build.rs LibJS: Add per-field bytecode validation generated from Bytecode.def 2026-05-03 08:43:19 +02:00
Cargo.toml LibJS: Allocate local variable indices in source order 2026-04-27 08:04:11 +02:00
cbindgen.toml LibJS: Add bytecode validator scaffolding driven from Bytecode.def 2026-05-03 08:43:19 +02:00