Build with ASAN on macOS by default.

This commit is contained in:
Nicholas Marriott
2026-07-12 13:26:25 +01:00
parent 6fd9987632
commit 330bedfb47
4 changed files with 24 additions and 2 deletions

View File

@@ -43,7 +43,8 @@ AM_CPPFLAGS += -DDEBUG
endif
AM_CPPFLAGS += -iquote.
if IS_ASAN
AM_CFLAGS += -fsanitize=address
AM_CPPFLAGS += -DASAN
AM_CFLAGS += -fsanitize=address -fno-omit-frame-pointer
AM_LDFLAGS += -fsanitize=address
endif
endif

View File

@@ -78,7 +78,7 @@ AC_ARG_ENABLE(
asan,
AS_HELP_STRING(--enable-asan, enable ASAN build flags),
,
enable_asan=no
[case "x$host_os" in *darwin*) enable_asan=yes;; esac]
)
AM_CONDITIONAL(IS_ASAN, test "x$enable_asan" = xyes)

3
grid.c
View File

@@ -366,6 +366,9 @@ grid_create(u_int sx, u_int sy, u_int hlimit)
if (gd->sy != 0)
gd->linedata = xcalloc(gd->sy, sizeof *gd->linedata);
#ifdef __APPLE__
assert(gd->hsize == 0);
#endif
grid_check_is_clear(gd);
return (gd);
}

18
tmux.c
View File

@@ -49,6 +49,24 @@ static char *make_label(const char *, char **);
static int areshell(const char *);
static const char *getshell(void);
#ifdef ASAN
__attribute__((used)) const char *__asan_default_options(void);
__attribute__((used)) const char *
__asan_default_options(void)
{
return (
"abort_on_error=1:"
"halt_on_error=1:"
"detect_leaks=0:"
"detect_stack_use_after_return=1:"
"strict_string_checks=1:"
"check_initialization_order=1:"
"log_path=/tmp/tmux-asan:"
"log_exe_name=1"
);
}
#endif
static __dead void
usage(int status)
{