ravi688 / VulkanRenderer

Spectrum Graphics Engine, 3D Renderer built on Vulkan API which works on Linux and Windows
https://www.youtube.com/@phymacillustrator/videos
GNU General Public License v3.0
23 stars 2 forks source link

Heap Corruption when MEMORY_ALLOCATION_SAFETY_LEVEL_2 is enabled #84

Closed ravi688 closed 6 months ago

ravi688 commented 1 year ago

Describe the bug Enabling MEMORY_ALLOCATION_SAFETY_LEVEL_2 uses SafeMemory module for allocation, deallocate and reallocate memory. But there is a problem in checked_aligned_malloc and checked_aligned_realloc functions, leading to heap corruption.

To Reproduce Steps to reproduce the behavior:

  1. Enable MEMORY_ALLOCATION_SAFETY_LEVEL_2 flag in the main makefile of VulkanRenderer
  2. Clean and Re-build the build
  3. Run the test DEPTH_RENDER_TEXTURE in gdb and application verifier
  4. The heap corruption might occur during the loop
  5. Or when you terminate the application by closing the window

Expected behavior There shouldn't be any breaks while running in gdb

Screenshots image

Additional context There might be a need to precisely implement custom aligned allocators, and reallocators.

ravi688 commented 6 months ago

We won't be using SafeMemory in future as we have more qualified tools for memory leak detection and invalid memory access detection.

Closing this issue.