LALMalloc: include file:line info in meminfo (memory tracking) messages
Description
The LAL memory tracing feature, enabled with LAL_DEBUG_LEVEL=msglvl3,memtrace
, is useful for debugging memory issues. The current output looks like:
$ env LAL_DEBUG_LEVEL=msglvl3,memtrace ./bin/lal_version >/dev/null
LALRealloc meminfo: allocating 63 bytes at address 0x559f37aee2b0
LALFree meminfo: freeing 63 bytes at address 0x559f37aee2b0
LALCheckMemoryLeaks meminfo: no memory leaks detected
While this tells you the address of the allocated memory, it doesn't tell you where in LAL the memory was allocated, which can be useful.
This MR adds that information, so that the above output is now:
$ env LAL_DEBUG_LEVEL=msglvl3,memtrace ./bin/lal_version >/dev/null
LALRealloc meminfo: allocating 63 bytes at address 0x5565df8042b0 in LALString.c:80
LALFree meminfo: freeing 63 bytes at address 0x5565df8042b0 in version.c:60
LALCheckMemoryLeaks meminfo: no memory leaks detected
This is relatively easy to do, as the functions LALMallocLong()
, LALCallocLong()
, etc. already collect that information; it just needed to be passed on to the internal functions PadAlloc()
, UnPadAlloc()
, etc.
The one exception was LALFree()
for which there was no ...Long()
form. This MR now defines LALFree()
as a macro instead of a function, following the same pattern as LAL{Malloc,Calloc,Realloc}{Short,Long}
. To avoid a backward-incompatible ABI change in liblal.so
, LALFree()
is still available as a function defined in LALMalloc.c
(although it is not declared in any header file), so that any dependent libraries that expect to find a function LALFree()
in liblal.so
will do so, and therefore should not require re-linking.
API Changes and Justification
Backwards Compatible Changes
-
This change does not modify any class/function/struct/type definitions in a public C header file or any Python class/function definitions -
This change adds new classes/functions/structs/types to a public C header file or Python module
Backwards Incompatible Changes
-
This change modifies an existing class/function/struct/type definition in a public C header file or Python module -
This change removes an existing class/function/struct/type from a public C header file or Python module
LALMalloc.h
now declares LALFree()
to be a macro rather than a function, but LALMalloc.c
still defines a function LALFree
which is exported by liblal.so
:
$ nm lib/.libs/liblal.so | grep ' LALFree$'
0000000000025ea0 T LALFree
So this should hopefully be a backward-compatible ABI change.