1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-05 20:58:40 +03:00

lib/util: Prefer backtrace_symbols() for internal backtraces

Backtraces when Samba is in PANIC state are better with
backtrace_symbols() than with libunwind on Ubuntu 20.04 x86_64
so move libunwind to a off-by-default option, prompted for
if backtrace_symbols() is not available.

Based on a request by Fco Javier Felix <ffelix@inode64.com>

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2022-06-07 15:07:59 +12:00
parent bd09537e21
commit 14feb93d48
4 changed files with 39 additions and 13 deletions

View File

@ -222,9 +222,13 @@ _PUBLIC_ void smb_panic(const char *why)
void log_stack_trace(void)
{
#ifdef HAVE_LIBUNWIND
/* Try to use libunwind before any other technique since on ia64
* libunwind correctly walks the stack in more circumstances than
* backtrace.
/*
* --with-libunwind is required to use libunwind, the
* backtrace_symbols() code below is the default.
*
* This code is available because a previous version of this
* comment asserted that on ia64 libunwind correctly walks the
* stack in more circumstances than backtrace.
*/
unw_cursor_t cursor;
unw_context_t uc;

View File

@ -2,6 +2,15 @@ def options(opt):
''' This is a bit strange, but disable is the flag, not enable. '''
opt.add_option('--disable-fault-handling', action='store_true', dest='disable_fault_handling', help=('disable the fault handlers'), default=False)
# We do not want libunwind by default (backtrace_symbols() in
# glibc is better) but allow (eg) IA-64 to build with it where it
# might be better (per old comment in fault.c)
opt.samba_add_onoff_option('libunwind',
default=None,
help='''Use libunwind instead of the default backtrace_symbols()
from libc, for example on IA-64 where it might give a better
backtrace.''')
opt.add_option('--with-systemd',
help=("Enable systemd integration"),
action='store_true', dest='enable_systemd')

View File

@ -1,23 +1,35 @@
#!/usr/bin/env python
from waflib import Logs, Options
from waflib import Logs, Options, Errors
import os, sys
if Options.options.disable_fault_handling:
conf.DEFINE('HAVE_DISABLE_FAULT_HANDLING',1)
# backtrace could be in libexecinfo or in libc
# backtrace could be in libexecinfo or in libc.
# This is our preferred backtrace handler (more useful output than libunwind as at Ubuntu 20.04 x86_64)
conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h')
conf.CHECK_HEADERS('execinfo.h')
conf.SET_TARGET_TYPE('LIBUNWIND', 'EMPTY')
if conf.check_cfg(package='libunwind-generic',
args='--cflags --libs',
msg='Checking for libunwind',
uselib_store='LIBUNWIND',
mandatory=False):
if conf.CHECK_HEADERS('libunwind.h'):
conf.SET_TARGET_TYPE('LIBUNWIND', 'SYSLIB')
if Options.options.with_libunwind:
if conf.check_cfg(package='libunwind-generic',
args='--cflags --libs',
msg='Checking for libunwind',
uselib_store='LIBUNWIND',
mandatory=False):
if conf.CHECK_HEADERS('libunwind.h'):
conf.SET_TARGET_TYPE('LIBUNWIND', 'SYSLIB')
else:
raise Errors.WafError('--with-libunwind specified but libunwind not found')
elif Options.options.with_libunwind == None:
if not conf.CONFIG_SET('HAVE_BACKTRACE_SYMBOLS') \
and not Options.options.disable_fault_handling:
raise Errors.WafError(
'''backtrace_symbols() not found but
--with-libunwind not specified.
Use --without-libunwind to build without internal backtrace support or
--disable-fault-handling to totally defer fault handling to the OS.''')
conf.CHECK_STRUCTURE_MEMBER('struct statvfs', 'f_frsize', define='HAVE_FRSIZE', headers='sys/statvfs.h')

View File

@ -480,10 +480,11 @@ tasks = {
# MIT Kerberos from the current system. Runtime behaviour is
# confirmed via the ktest (static ccache and keytab) environment
# This environment also used to confirm we can still build with --with-libunwind
"samba-ktest-mit": {
"sequence": [
("random-sleep", random_sleep(300, 900)),
("configure", "./configure.developer --without-ad-dc --with-system-mitkrb5 " + samba_configure_params),
("configure", "./configure.developer --without-ad-dc --with-libunwind --with-system-mitkrb5 " + samba_configure_params),
("make", "make -j"),
("test", make_test(include_envs=[
"ktest", # ktest is also tested in fileserver, samba and