Hello list, I would like to summarize an issue [1] that first came up on the FreeBSD bugzilla for Guile 3.0.10. It's a segfault due to the incorrect mixing of two separate APIs for Posix spawn.
As Tobias Kortkamp clarifies there, the gnulib rpl_posix_spawn*() functions are picked up by Guile's autotools. However, posix_spawn_file_actions_addclosefrom_np() does not have a gnulib implementation. On the other hand, Guile's configure.ac detects the function as available on FreeBSD 13 (because FreeBSD 13.1 implemented it [2]). There is only one place where all of this matters, libguile/posix.c, and I want to explain how. AC_CHECK_FUNCS in configure.ac is processed by autoheader(1) which sets up a macro HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSEFROM_NP when it can successfully load a test program with that function. The macro is renamed in libguile/posix.c to HAVE_ADDCLOSEFROM (for brevity probably): #ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSEFROM_NP # define HAVE_ADDCLOSEFROM 1 #endif Then it is used in 2 places in that file: a) A fallback function close_inherited_fds() is defined if posix_spawn_file_actions_addclosefrom_np() is missing. b) Inside do_spawn, if posix_spawn_file_actions_addclosefrom_np() exists it is used, otherwise the fallback function is used. It is at b) where the segfault occurs: gnulib has a "fallback" spawn implementation that is incompatible with posix_spawn_file_actions_addclosefrom_np but compatible with close_inherited_fds(). Nevertheless, currently on FreeBSD 14, the gnulib implementation is used with the native posix_spawn_file_actions_addclosefrom_np() which causes a segfault. Further discussion on the issue [3,4] and the PR that attempts to fix some of it. [5] Ideally we want to use native functions on FreeBSD instead of gnulib's. currently the patch in [5] is avoiding use of posix_spawn_file_actions_addclosefrom_np() on any platform where HAVE_POSIX_SPAWN is not defined. 1. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282534 2. https://cgit.freebsd.org/src/commit/?id=a18ddf775744f31a844fd01fbe90207f7c5e706d 3. https://logs.guix.gnu.org/guile/2025-09-22.log 4. https://logs.guix.gnu.org/guile/2025-09-23.log 5. https://codeberg.org/guile/guile/pulls/17