mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
This is the first part of Bug 466104 aligned_alloc problems, part 1 The bulk of this change is try try to get memalign to be more platform aware. Previously the Valgrind implementation only reflected the glibc implementation. That meant non-power of two alignment values would silently get bumped up to the next largest power of two. Most other platforms return NULL and set errno to EINVAL. There are a few other changes. A couple of the other aligned alloc functions like valloc were caling the Valgrind memalign. This meant that there weould be an extra Valgrind memalign in any error callstacks. Now these functions call the allocator directly. The memcheck memalign2 testcase has been redone. The memalign parts moved out to per-platform versions and the tescase itdelf renamed to posix_memalign, since that is all that is left. I also modified the testcase so that it checks that the memalign calls check for non-NULL returns, and on platforms that set errno that it is correctly set. Previously the test only worked on non-glibc because NULL & alignment is zero. The platform versions have been tested on glibc, MUSL, FreeBSD and OpenIndiana and should hopefully run OK both under memcheck and standalone. There is stil quite a lot that is NOT done 1. I'm not certain that implementations allocate more memory and/or use a wider alignment. It doesn't help that almost universally the memalign implementations are badly documented, undocumented or buggy. 2. We don't handle very large alignment requests well. Most implementations will fail and set EINVAL if the alignment is over half the memory space. Valgrind will core panic if an aligmnt of over 16Mbytes is requested. 3. We don't generate any memcheck errors for invalid values of alignment. That's planned in Part 2. 4. The code is static and fixed at compile time. That means that if you are using MUSL with a glibc-built Valgrind you will still get glibc memalign behaviour. I'll wait to see if there are any requests before trying to make the behaviour selectable at runtime.
19 lines
473 B
Plaintext
19 lines
473 B
Plaintext
Invalid read of size 8
|
|
...
|
|
Address 0x........ is 0 bytes inside a block of size 5 alloc'd
|
|
at 0x........: posix_memalign (vg_replace_malloc.c:...)
|
|
...
|
|
|
|
Invalid read of size 8
|
|
...
|
|
Address 0x........ is 0 bytes inside a block of size 5 alloc'd
|
|
at 0x........: posix_memalign (vg_replace_malloc.c:...)
|
|
...
|
|
|
|
Invalid read of size 8
|
|
...
|
|
Address 0x........ is 8 bytes inside a block of size 24 free'd
|
|
at 0x........: free (vg_replace_malloc.c:...)
|
|
...
|
|
|