From 0186c63a174083b2c5c556a94052a7d1144314bc Mon Sep 17 00:00:00 2001 From: Kyle Ambroff-Kao Date: Sun, 22 Dec 2019 22:36:06 -0800 Subject: [PATCH] tmux: Fix crash loading config (#4477) The tmux code depends on some BSD functionality, namely fparseln, when parsing configs. This is called in load_cfg during startup after finding the appropriate config file to load. On platforms where fparseln isn't available, tmux uses a polyfill library called compat that it ships with, which includes a fork of the FreeBSD fparseln function. The autoconf script for tmux searches the libutil header for fparseln in order to determine whether to use this compat library or the fparseln from the the system. Before this patch, on my x86_64 system at least, tmux would crash on startup trying to load $HOME/.tmux.conf. It turns out that this is because on Haiku, the FreeBSD compatibility in libutil code is disabled in /system/develop/headers/bsd/features.h unless either _BSD_SOURCE is defined. #if defined(_BSD_SOURCE) \ || (!defined(__STRICT_ANSI__) && !defined(_POSIX_C_SOURCE)) #define _DEFAULT_SOURCE #endif Since _BSD_SOURCE is not defined, and _POSIX_C_SOURCE *is* defined (because the compiler is given -std=gnu99), then _DEFAULT_SOURCE is never defined. The end result is that fparseln is visible to autoconf, but is not visible to the compiler when compiling cfg.c. This leads fparseln to be implicitly defined, which changes the return type from char* to int, and that conversion can cause a SEGFAULT. The effect of this patch is to just define _BSD_SOURCE so that the FreeBSD compat code is visible to the compiler, which produces a tmux binary that works as expected. --- app-misc/tmux/patches/tmux-2.8.patchset | 22 ++++++++++++++++++++++ app-misc/tmux/tmux-2.8.recipe | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app-misc/tmux/patches/tmux-2.8.patchset b/app-misc/tmux/patches/tmux-2.8.patchset index bb7b53d57..8f3e71812 100644 --- a/app-misc/tmux/patches/tmux-2.8.patchset +++ b/app-misc/tmux/patches/tmux-2.8.patchset @@ -195,3 +195,25 @@ index 5cce1d9..32ec9c0 100644 -- 2.19.1 + +From d9afd73806dcedf441ba42f36f42c383564919af Mon Sep 17 00:00:00 2001 +From: Kyle Ambroff-Kao +Date: Sun, 22 Dec 2019 17:23:29 -0800 +Subject: Define _BSD_SOURCE to expose freebsd compat in libutil + + +diff --git a/configure.ac b/configure.ac +index 32ec9c0..a131f9b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -461,6 +461,7 @@ fi + AC_SEARCH_LIBS(fparseln, util, found_fparseln=yes, found_fparseln=no) + if test "x$found_fparseln" = xyes; then + AC_DEFINE(HAVE_FPARSELN) ++ AC_DEFINE(_BSD_SOURCE) + else + AC_LIBOBJ(fparseln) + fi +-- +2.24.1 + diff --git a/app-misc/tmux/tmux-2.8.recipe b/app-misc/tmux/tmux-2.8.recipe index ca9af330f..6b1a0b035 100644 --- a/app-misc/tmux/tmux-2.8.recipe +++ b/app-misc/tmux/tmux-2.8.recipe @@ -6,7 +6,7 @@ such as GNU screen." HOMEPAGE="http://tmux.github.io/" COPYRIGHT="2015 tmux team" LICENSE="ISC" -REVISION="2" +REVISION="3" SOURCE_URI="https://github.com/tmux/tmux/releases/download/$portVersion/tmux-$portVersion.tar.gz" CHECKSUM_SHA256="7f6bf335634fafecff878d78de389562ea7f73a7367f268b66d37ea13617a2ba" PATCHES="tmux-$portVersion.patchset"