cldellow / libfailmalloc

Patched version of http://www.nongnu.org/failmalloc/ that compiles under modern g++
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Fails to build: `error: '__malloc_hook' undeclared (first use in this function); did you mean 'old_malloc_hook'?` #1

Open Zopolis4 opened 4 months ago

Zopolis4 commented 4 months ago

Configured with: CFLAGS="-O2 -pipe -ffat-lto-objects -fPIC -fuse-ld=mold -flto=auto" CXXFLAGS="-O2 -pipe -ffat-lto-objects -fPIC -fuse-ld=mold -flto=auto" FCFLAGS="-O2 -pipe -ffat-lto-objects -fPIC -fuse-ld=mold -flto=auto" FFLAGS="-O2 -pipe -ffat-lto-objects -fPIC -fuse-ld=mold -flto=auto" LD_LIBRARY_PATH="/usr/local/lib64" LDFLAGS="-flto=auto " ./configure --prefix=/usr/local --libdir=/usr/local/lib64 --mandir=/usr/local/share/man --disable-dependency-tracking --build=x86_64-cros-linux-gnu --host=x86_64-cros-linux-gnu --target=x86_64-cros-linux-gnu --program-prefix='' --program-suffix=''

chronos@0a42bf304461 ~/libfailmalloc $ make
cd . && \
  /bin/sh /home/chronos/user/libfailmalloc/missing --run automake-1.7 --gnu  Makefile
/home/chronos/user/libfailmalloc/missing: 46: automake-1.7: not found
WARNING: `automake-1.7' is missing on your system.  You should only need it if
         you modified `Makefile.am', `acinclude.m4' or `configure.ac'.
         You might want to install the `Automake' and `Perl' packages.
         Grab them from any GNU archive site.
cd . && /bin/sh ./config.status Makefile depfiles
config.status: creating Makefile
config.status: executing depfiles commands
/bin/sh ./libtool --mode=compile x86_64-cros-linux-gnu-gcc -DPACKAGE_NAME=\"failmalloc\" -DPACKAGE_TARNAME=\"failmalloc\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"failmalloc\ 1.0\" -DPACKAGE_BUGREPORT=\"okuji@enbug.org\" -DPACKAGE=\"failmalloc\" -DVERSION=\"1.0\" -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_MALLOC_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_STDLIB_H=1 -DHAVE_REALLOC=1 -DHAVE_STRTOUL=1  -I. -I.     -O2 -pipe -ffat-lto-objects -fPIC  -fuse-ld=mold  -flto=auto -c -o failmalloc.lo `test -f 'failmalloc.c' || echo './'`failmalloc.c
mkdir .libs
 x86_64-cros-linux-gnu-gcc -DPACKAGE_NAME=\"failmalloc\" -DPACKAGE_TARNAME=\"failmalloc\" -DPACKAGE_VERSION=\"1.0\" "-DPACKAGE_STRING=\"failmalloc 1.0\"" -DPACKAGE_BUGREPORT=\"okuji@enbug.org\" -DPACKAGE=\"failmalloc\" -DVERSION=\"1.0\" -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_MALLOC_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DHAVE_STDLIB_H=1 -DHAVE_REALLOC=1 -DHAVE_STRTOUL=1 -I. -I. -O2 -pipe -ffat-lto-objects -fPIC -fuse-ld=mold -flto=auto -c failmalloc.c  -fPIC -DPIC -o .libs/failmalloc.o
failmalloc.c: In function 'failmalloc_install':
failmalloc.c:136:21: error: '__malloc_hook' undeclared (first use in this function); did you mean 'old_malloc_hook'?
  136 |   old_malloc_hook = __malloc_hook;
      |                     ^~~~~~~~~~~~~
      |                     old_malloc_hook
failmalloc.c:136:21: note: each undeclared identifier is reported only once for each function it appears in
failmalloc.c:137:22: error: '__realloc_hook' undeclared (first use in this function); did you mean 'old_realloc_hook'?
  137 |   old_realloc_hook = __realloc_hook;
      |                      ^~~~~~~~~~~~~~
      |                      old_realloc_hook
failmalloc.c:138:23: error: '__memalign_hook' undeclared (first use in this function); did you mean 'old_memalign_hook'?
  138 |   old_memalign_hook = __memalign_hook;
      |                       ^~~~~~~~~~~~~~~
      |                       old_memalign_hook
failmalloc.c: In function 'failmalloc_uninstall':
failmalloc.c:147:3: error: '__malloc_hook' undeclared (first use in this function); did you mean 'old_malloc_hook'?
  147 |   __malloc_hook = old_malloc_hook;
      |   ^~~~~~~~~~~~~
      |   old_malloc_hook
failmalloc.c:148:3: error: '__realloc_hook' undeclared (first use in this function); did you mean 'old_realloc_hook'?
  148 |   __realloc_hook = old_realloc_hook;
      |   ^~~~~~~~~~~~~~
      |   old_realloc_hook
failmalloc.c:149:3: error: '__memalign_hook' undeclared (first use in this function); did you mean 'old_memalign_hook'?
  149 |   __memalign_hook = old_memalign_hook;
      |   ^~~~~~~~~~~~~~~
      |   old_memalign_hook
make: *** [Makefile:255: failmalloc.lo] Error 1

Seems like these functions were dropped in glibc 2.34: https://sourceware.org/pipermail/libc-alpha/2021-August/129718.html

* The deprecated memory allocation hooks __malloc_hook, __realloc_hook,
  __memalign_hook and __free_hook are now removed from the API.  Compatibility
  symbols are present to support legacy programs but new applications can no
  longer link to these symbols.  These hooks no longer have any effect on glibc
  functionality.  The malloc debugging DSO libc_malloc_debug.so currently
  supports hooks and can be preloaded to get this functionality back for older
  programs.  However this is a transitional measure and may be removed in a
  future release of the GNU C Library.  Users may port away from these hooks by
  writing and preloading their own malloc interposition library.

Looks like __libc_malloc should work? https://stackoverflow.com/questions/17803456/an-alternative-for-the-deprecated-malloc-hook-functionality-of-glibc

cldellow commented 4 months ago

Hello! Thanks for reporting this. Hopefully it will be useful to anyone else who stumbles across this repo.

I monkey-see/monkey-do'd this repo just enough to get it working so I could do some memory testing of https://github.com/cldellow/sqlite-parquet-vtable in 2018.

I've since moved on from that project, so I don't maintain this repo any longer.

Candidly, I also no longer understand much of what you just wrote. My mind isn't so much a sieve as a colander, and most of the C stuff has fallen out since then. :)

Zopolis4 commented 4 months ago

Fair enough, no worries.