SegFault in cache code
Dear XFS developers,
I use the libxfs library from xfsprogs 6.16.0. With the following short program I see a segmentation fault when I set the environment variable LIBXFS_LEAK_CHECK, e. g.
gcc init_destroy_test.c -I../include -L../lib -lxfs -lfrog -lurcu -luuid LIBXFS_LEAK_CHECK=1 ./a.out
---cut---
#include <stdlib.h>
#include <stdio.h>
#include <xfs/libxfs.h>
int main(int argc, const char *argv[])
{
struct libxfs_init libXFSInit;
memset(&libXFSInit,0,sizeof(libXFSInit));
libxfs_init(&libXFSInit);
libxfs_destroy(&libXFSInit);
return 0;
}
---cut---
I'm not sure if this behaviour is known and intented.
A fix may be a NULL-pointer check in destroy_caches(). E. g. the gdb stack trace says:
Program received signal SIGSEGV, Segmentation fault. 0x000055555555c130 in kmem_cache_destroy (cache=0x0) at kmem.c:35
35 if (getenv("LIBXFS_LEAK_CHECK") && cache->allocated) {
(gdb) bt
#0 0x000055555555c130 in kmem_cache_destroy (cache=0x0) at kmem.c:35 #1 0x000055555555bab9 in destroy_caches () at init.c:239 #2 libxfs_destroy (li=<optimized out>) at init.c:1059 #3 0x0000555555559d2b in main ()
Best regards,
Torsten Rupp