fix: preserve Win32 allocator alignment across free and resize - #3
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe Windows allocator now validates allocation sizes and alignments, stores metadata for aligned blocks, and uses that metadata to reallocate and free memory. ChangesWindows allocator
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The Windows allocator now records each block's original address and alignment. Aligned allocations are freed and resized correctly, which fixes the reported heap-corruption crash in image-demo. No remaining defect was found in the Windows target code. Shared framework code built from external packages could not be inspected, so owners should confirm it never frees allocator memory with the C runtime directly. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Problem
image-democrashes on its first animation frame with Windows exit code0xC0000374. The canvas store requests a 128-byte-aligned pixel buffer. Win32Allocator::allocatePreferSpiramreturned_aligned_mallocmemory for that request, whileAllocator::freepassed the pointer tostd::free. AddressSanitizer identifies this mismatched free inCanvasStore::bindDisplayFramebuffer.Change
Store the underlying
mallocblock and requested alignment with each allocation. Return an aligned view, preserve that alignment and existing bytes when resizing, and free the underlying block through the matching allocator.Verification
image-demobuild exited on tick 1 with0xC0000374; AddressSanitizer reported an invalid free atwin32_memory.cpp:31.notes-jsxbuilt, exited 0 throughGEA_WINDOWS_VERIFY_ONCE, and rendered its initial notes view.Summary by CodeRabbit