zakarumych / gpu-alloc

Implementation agnostic memory allocator for Vulkan-like APIs
Other
86 stars 18 forks source link

Fix aligning of mapped size for a block #29

Closed kvark closed 3 years ago

kvark commented 3 years ago

Could be related to #27 I believe the following line was wrong:

let aligned_size = offset + size - aligned_offset;

Given that size is aligned, aligned_offset is aligned, but offset is not necessarily aligned, we get a situation where aligned_size is not aligned. Moreover, it's less than the required size for mapping, which can lead to EXC_BAD_ACCESS upon writing to it.