Repository navigation
v0.16.1
Patch release. Replaces bare integer arithmetic in Position with
saturating variants, matching the pattern already used in
Portfolio::execute_fill. Found by fuzz_execute_fill (added in v0.16.0
as part of the property-based testing pass after the v0.16.0 ship).
Fixed
Position::market_valueoverflow (src/portfolio/position.rs:95):
self.quantity * pricepreviously panicked oni64overflow.
Replaced withsaturating_mul. Reachable via the public
Portfolio::rebalance_simpleAPI; crash artifact preserved at
fuzz/artifacts/fuzz_execute_fill/crash-330fb9097052e84d78571d06b840334680573582.Position::unrealized_pnloverflow (position.rs:104): same root
cause; both the subtraction and multiplication now saturate.Position::apply_filloverflow (lines 55, 58, 69, 80, 87): all
intermediate products/sums switched to saturating variants. Real-world
trigger requires extreme quantity × price products; bug was latent
pre-v0.16.0 but only surfaced after the fuzz harness was added.Portfolio::total_equity_from_price_mapoverflow (src/portfolio/mod.rs:430-435):
bare.sum()overpos.market_value(price)and bareself.cash + position_value
could panic when many large positions accumulated. Replaced withsaturating_*.
Found byfuzz_execute_fillre-run after the position.rs fix landed (crash artifact
crash-6bafbd4544cfff56e4ac3e2d68e18ebeecf6c2d7).Portfolio::rebalance_simplearithmetic (src/portfolio/mod.rs:238, 285, 346, 385):
defensivesaturating_*replacements at five other i64 arithmetic sites in
the rebalance / equity / price-mid paths. Each was a latent overflow risk
reachable through the public API under extreme inputs.Portfolio::snapshottotal_realized_pnloverflow (src/portfolio/mod.rs:397)
[Inference]: bare.sum()overpos.realized_pnlfields — same pattern as the
total_equity_from_price_mapbug; replaced withsaturating_addfold. Not in the
original fuzz crash path but reachable from the same extreme-input scenarios.
Added
tests/regression_position_overflow.rs: integration tests that
assert each previously-crashing input sequence now returns a saturated
i64 instead of panicking. Replays the libfuzzer crash artifact by hand.