You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Silent u16 truncation in symbolic bytecode symbolize functions #291
In src/simlin-engine/src/compiler/symbolic.rs, two casts silently truncate values when converting to u16:
symbolize_static_view casts view.base_off (a u32) to u16
symbolize_module_decl casts decl.off (a usize) to u16
Both casts will silently truncate if the value exceeds 65535. For sufficiently large models, this would corrupt the symbolic representation without any error signal.
Why It Matters
The symbolic bytecode path is still development/test-only, but before it goes live to production, this data loss pathway must be eliminated. Silent truncation of offsets corrupts the symbolic information without any diagnostic.
Current State
This is currently dead/scaffold code (only used in tests), so there is no immediate impact. However, this pattern is a correctness risk.
Resolution Approach
Replace the silent casts with explicit bounds checking:
Use u16::try_from().unwrap() or similar, which will panic if a value exceeds u16 bounds
Or add explicit bounds checking before conversion with proper error handling
Add tests that verify large offset values are rejected or handled correctly
Activity
engine: incremental salsa sync, u16 truncation fix, and coverage
engine: incremental salsa sync, u16 truncation fix, and coverage
Incremental compilation via salsa framework (#289)