fix: deep dive systematic fixes - race conditions, memory safety, robustness#63
Conversation
…ustness Streaming video (Critical): - Fix base_offset race condition: restart decision + buffer mutation now happen inside a single lock acquisition, preventing data corruption when the tail probe thread concurrently modifies base_offset - Add MAX_HEADER_SIZE (64KB) limit to all HTTP header parsing loops to prevent unbounded heap growth from malicious/broken servers - Replace string-based WouldBlock detection with is_would_block() helper for robustness across Rust versions - Wrap moov data in Arc<Vec<u8>> to eliminate redundant multi-MB clones in wait_for_moov() (was cloning 1-4MB per call) - Add MAX_ATOM_SIZE (10GB) validation in scan_atoms to prevent integer overflow from corrupt MP4 atom headers - Replace polling loop in Seek::End with deadline-based timeout PSP backend: - Add Drop impl for VolatileAllocator to call sceKernelVolatileMemUnlock, preventing 4MB memory leak on abnormal exit - Make AAC decoder init retryable (3 attempts) instead of permanently giving up on first failure -- handles transient EDRAM shortages - Replace magic codec type 0x1003 with named CODEC_TYPE_AAC constant - Document and centralize PSP socket option constants (PSP_SOL_SOCKET, PSP_SO_NONBLOCK, PSP_SO_NBIO, PSP_SO_SNDTIMEO, PSP_SO_RCVTIMEO) with explanations of how they differ from Linux/BSD values - Replace inline magic numbers in radio.rs and tls_http.rs with the centralized constants from network.rs - Add debug_assert for font_atlas_ptr null check before uncached pointer conversion to catch initialization ordering bugs - Log DMA memcpy failures (once per texture) instead of silently falling back to CPU copy FFI: - Add recommended UE5 threading pattern (FCriticalSection) to the module documentation to help integrators avoid undefined behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The PSP backend doesn't have the `log` crate available. Remove debug log from VolatileAllocator::Drop and revert DMA error handling to the original .is_ok() pattern (psp::dma::memcpy_dma returns DmaResult, not ()). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… rev pin - demux_lite: use saturating arithmetic in read_desc_len() to prevent integer overflow on malicious MP4 esds box inputs - browser LRU cache: replace expect() panics with graceful fallthrough using get()/get_mut() bounds checks (prevents crash on corrupted state) - ffmpeg_decoder: add missing // SAFETY: comments on unsafe blocks in error cleanup paths and codec context operations - oasis-plugin-psp: pin rust-psp to rev 4370415 (was 4c47345), matching oasis-backend-psp. Picks up DNS endianness fix and weak videocodec import Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Gemini AI Code ReviewIssues (if any)
Previous Issues (for incremental reviews)(none) Suggestions (if any)
Notes
Generated by Gemini AI (gemini-3.1-pro-preview). Supplementary to human reviews. |
Automated fix by Claude in response to Gemini/Codex review. Iteration: 1/5 Co-Authored-By: AI Review Agent <noreply@anthropic.com>
Review Response Agent (Iteration 1)Status: Changes committed, pushing... Commit: Fixed Issues
Ignored Issues
Deferred to Human
Notes
Automated summary of agent fixes. |
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Previous Issues (for incremental reviews)
Issues (if any)(none) Suggestions (if any)
Notes
Generated by Gemini AI (gemini-3.1-pro-preview). Supplementary to human reviews. |
Review Response Agent (Iteration 2)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Automated fix by Claude in response to pipeline failures. Failures addressed: - format - lint - test-suite Actions taken: - Ran autoformat (ruff format, cargo fmt) - Fixed remaining lint issues Iteration: 1/5 Co-Authored-By: AI Pipeline Agent <noreply@anthropic.com>
Failure Handler Agent (Iteration 1)Status: Changes committed, pushing... Commit: Failures addressed:
Automated fix in response to CI pipeline failures. |
Gemini AI Incremental ReviewThis is an incremental review focusing on changes since the last review. Issues (if any)(none) Previous Issues (for incremental reviews)
Suggestions (if any)(none) Notes
Generated by Gemini AI (gemini-3.1-pro-preview). Supplementary to human reviews. |
Review Response Agent (Iteration 3)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Summary
download.rs, preventing the tail probe thread from corruptingbase_offsetbetween two separate lock callsVec<u8>cloning toArc<Vec<u8>>sharing across the streaming pipeline (saves 1-3MB per clone)MAX_ATOM_SIZEvalidation inscan_atoms,MAX_HEADER_SIZEbounds on HTTP header parsing, deadline-based timeout replacing unbounded polling inSeek::EndPSP_SOL_SOCKET,PSP_SO_NONBLOCK, etc.), addedVolatileAllocatorDrop impl for memory unlock, AAC decoder retry logic (3 attempts instead of permanent failure), font atlas null-pointer debug assertoasis-ffiis_would_block()helper replacing 8 inline string-match patternsTest plan
cargo test --workspace)cargo clippy --workspace -- -D warnings)cargo fmt --all -- --check)Generated with Claude Code (https://claude.com/claude-code)