IMCG / nvm-malloc

Other
30 stars 6 forks source link

Memory reserved by nvm_reserve is less than memory requested #1

Open nisargshah95 opened 4 years ago

nisargshah95 commented 4 years ago

Is the the following scenario possible? If I request a 4096 byte allocation, only one block (4096 bytes) is reserved at ptr and ptr+64 is returned (to account for the header?), so I only have 4096-64 bytes to use. If I understand correctly the reservation does not account for this and therefore a reservation right of the edge of a small/large request overflows. The same case applies when a new run is created. I have applied the following workaround for now - increase requested size by 64 in nvm_reserve.

ypluo commented 4 years ago

I encounter the same problem as I allocated 4096 bytes. Unfortunately after I wrote this 4096 bytes and it overwrote the meta data (header) of another run, which led to a stuck on nvm_activate.

I solve it by add 64 bytes before roundup n_bytes to BLOCK_SIZE (at file:arena.c line:140), looks awful but works. U can also reference my fork