]> 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 01:50:56 +0000 (01:50 +0000)
commita9944a52c967ce76a5894c30d0274b824df43c7a
tree5337ce2a52201e1119ada9c0be09b34920e42ee9
parent28d102d15c6af7f80cb1077e098e020476d26d00
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>
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