r-lyeh-archived / ltalloc

LightweighT Almost Lock-Less Oriented for C++ programs memory allocator
BSD 3-Clause "New" or "Revised" License
164 stars 16 forks source link

ltmemalign failing returning aligned pointer #13

Closed gjaegy closed 6 years ago

gjaegy commented 6 years ago

Hi, I have come across an issue where ltmemalign() sometimes returns a pointer that's not aligned correctly.

This occurs with a x86 (32-bits) build, compiled with MSVC 2013.

The requested memory to allocate is 192 bytes, with a 4-bytes alignment.

Any idea ?

Thanks a lot !

PS: the returned pointer value is 0x3f2a3993 (which is clearly not 4-bytes aligned)

gjaegy commented 6 years ago

when running a 64-bits build, I get an access violation in the same code instead of an unaligned pointer:

image

r-lyeh-archived commented 6 years ago

Hey there,

  1. Are params in ltmemalign() call swapped by any chance?
  2. If that does not help, can you compile with: -DLTALLOC_SIZE_CLASSES_SUBPOWER_OF_TWO=0 or -DLTALLOC_SIZE_CLASSES_SUBPOWER_OF_TWO=1 to see if it helps? If it helps, then must be some kind of out of memory issue, I guess.
gjaegy commented 6 years ago

thanks for your reply!

Actually I think my own code creates the corruption :/ I will confirm this later today.

gjaegy commented 6 years ago

Indeed. I am the guilty one (as one could expect :))

So, will continue evaluating ltalloc. Excellent results so far (at least regarding fragmentation) !