From: Bernd Schubert Date: Wed, 20 Mar 2024 10:33:46 +0000 (+0100) Subject: Add glibc backtrace to signal handler X-Git-Tag: fuse-3.17.1-rc0~144^2~2 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e48c71d445f8b5557f45974eb0fcf5130b1e7b20;p=qemu-gpiodev%2Flibfuse.git Add glibc backtrace to signal handler It is very hard to see in github tests what is actually failing with signals - add the gnu-libc backtrace handler. --- diff --git a/lib/fuse_signals.c b/lib/fuse_signals.c index 048d047..4c1d172 100644 --- a/lib/fuse_signals.c +++ b/lib/fuse_signals.c @@ -16,15 +16,30 @@ #include #include #include +#include static struct fuse_session *fuse_instance; +static void dump_stack(void) +{ +#ifdef HAVE_BACKTRACE + const size_t backtrace_sz = 1024 * 1024; + void* backtrace_buffer[backtrace_sz]; + + int err_fd = fileno(stderr); + + int trace_len = backtrace(backtrace_buffer, backtrace_sz); + backtrace_symbols_fd(backtrace_buffer, trace_len, err_fd); +#endif +} + static void exit_handler(int sig) { if (fuse_instance) { fuse_session_exit(fuse_instance); if(sig <= 0) { fuse_log(FUSE_LOG_ERR, "assertion error: signal value <= 0\n"); + dump_stack(); abort(); } fuse_instance->error = sig; diff --git a/meson.build b/meson.build index 7d62dcf..7d8db7f 100644 --- a/meson.build +++ b/meson.build @@ -61,6 +61,8 @@ private_cfg.set('HAVE_SETXATTR', cc.has_function('setxattr', prefix: '#include ')) private_cfg.set('HAVE_ICONV', cc.has_function('iconv', prefix: '#include ')) +private_cfg.set('HAVE_BACKTRACE', + cc.has_function('backtrace', prefix: '#include ')) # Test if structs have specific member private_cfg.set('HAVE_STRUCT_STAT_ST_ATIM',