]> git.ipfire.org Git - thirdparty/glibc.git/commit
malloc: add indirection for malloc(-like) functions in tests [BZ #32366]
authorSam James <sam@gentoo.org>
Mon, 9 Dec 2024 23:11:25 +0000 (23:11 +0000)
committerSam James <sam@gentoo.org>
Tue, 10 Dec 2024 03:02:46 +0000 (03:02 +0000)
commit51da74a97e0f024fd89b57304b3ab010a3cfaef1
tree34879fede08fc6bfd86be08e47fcf3fa3e9df9f8
parentaa8768999e94fcee1695feb766c69dd8a93b706b
malloc: add indirection for malloc(-like) functions in tests [BZ #32366]

GCC 15 introduces allocation dead code removal (DCE) for PR117370 in
r15-5255-g7828dc070510f8. This breaks various glibc tests which want
to assert various properties of the allocator without doing anything
obviously useful with the allocated memory.

Alexander Monakov rightly pointed out that we can and should do better
than passing -fno-malloc-dce to paper over the problem. Not least because
GCC 14 already does such DCE where there's no testing of malloc's return
value against NULL, and LLVM has such optimisations too.

Handle this by providing malloc (and friends) wrappers with a volatile
function pointer to obscure that we're calling malloc (et. al) from the
compiler.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
(cherry picked from commit a9944a52c967ce76a5894c30d0274b824df43c7a)
malloc/tst-aligned-alloc.c
malloc/tst-compathooks-off.c
malloc/tst-malloc-aux.h [new file with mode: 0644]
malloc/tst-malloc-check.c
malloc/tst-malloc-too-large.c
malloc/tst-malloc.c
malloc/tst-realloc.c
support/support.h
test-skeleton.c