From 8978ca136a5fda4b1a6ae4d5ac293389d12db2bd Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Wed, 5 Aug 2026 02:05:53 -0400 Subject: [PATCH 1/4] gh-153711: Avoid use of dup3 and pipe2 calls introduced in macOS 27 This prevents potential segfaults when builds are used on older systems and avoids adding new code for supporting weaklinking. --- ...-08-05-02-02-33.gh-issue-153711.pO9fFb.rst | 2 ++ configure | 32 +++++++++++-------- configure.ac | 8 ++++- 3 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst diff --git a/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst new file mode 100644 index 00000000000000..2ca29b3fa951aa --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst @@ -0,0 +1,2 @@ +Do not attempt to use the `dup3` and `pipe2` system calls introduced in +macOS 27 to prevent problems when running on older systems. diff --git a/configure b/configure index 218f1ad35e2799..2cb22a7806fa55 100755 --- a/configure +++ b/configure @@ -20575,13 +20575,7 @@ fi # header definition prevents usage - autoconf doesn't use the headers), or # raise an error if used at runtime. Force these symbols off. if test "$ac_sys_system" != "iOS" ; then - ac_fn_c_check_func "$LINENO" "dup3" "ac_cv_func_dup3" -if test "x$ac_cv_func_dup3" = xyes -then : - printf "%s\n" "#define HAVE_DUP3 1" >>confdefs.h - -fi -ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy" + ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy" if test "x$ac_cv_func_getentropy" = xyes then : printf "%s\n" "#define HAVE_GETENTROPY 1" >>confdefs.h @@ -20592,12 +20586,6 @@ if test "x$ac_cv_func_getgroups" = xyes then : printf "%s\n" "#define HAVE_GETGROUPS 1" >>confdefs.h -fi -ac_fn_c_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" -if test "x$ac_cv_func_pipe2" = xyes -then : - printf "%s\n" "#define HAVE_PIPE2 1" >>confdefs.h - fi ac_fn_c_check_func "$LINENO" "system" "ac_cv_func_system" if test "x$ac_cv_func_system" = xyes @@ -20606,6 +20594,24 @@ then : fi +fi +# In addition, macOS introduced dup3 and pipe2 in macOS 27, late in the +# lifetime of this version of Python. Rather than adding weaklinking +# support for them, just continue to ignore them. +if test "$ac_sys_system" != "iOS" -a "$ac_sys_system" != "Darwin"; then + ac_fn_c_check_func "$LINENO" "dup3" "ac_cv_func_dup3" +if test "x$ac_cv_func_dup3" = xyes +then : + printf "%s\n" "#define HAVE_DUP3 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "pipe2" "ac_cv_func_pipe2" +if test "x$ac_cv_func_pipe2" = xyes +then : + printf "%s\n" "#define HAVE_PIPE2 1" >>confdefs.h + +fi + fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 diff --git a/configure.ac b/configure.ac index ba9a6fa35be9aa..967d34d47a3e1f 100644 --- a/configure.ac +++ b/configure.ac @@ -5361,7 +5361,13 @@ fi # header definition prevents usage - autoconf doesn't use the headers), or # raise an error if used at runtime. Force these symbols off. if test "$ac_sys_system" != "iOS" ; then - AC_CHECK_FUNCS([dup3 getentropy getgroups pipe2 system]) + AC_CHECK_FUNCS([getentropy getgroups system]) +fi +# In addition, macOS introduced dup3 and pipe2 in macOS 27, late in the +# lifetime of this version of Python. Rather than adding weaklinking +# support for them, just continue to ignore them. +if test "$ac_sys_system" != "iOS" -a "$ac_sys_system" != "Darwin"; then + AC_CHECK_FUNCS([dup3 pipe2]) fi AC_CHECK_DECL([dirfd], From 0793fee968995e75c4c30df55a84d780d5aed6b2 Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Wed, 5 Aug 2026 02:29:17 -0400 Subject: [PATCH 2/4] fix quotes --- .../next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst index 2ca29b3fa951aa..3260db9a2da1f9 100644 --- a/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst +++ b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst @@ -1,2 +1,2 @@ -Do not attempt to use the `dup3` and `pipe2` system calls introduced in +Do not attempt to use the ``dup3`` and ``pipe2`` system calls introduced in macOS 27 to prevent problems when running on older systems. From 786c3b0064649c1ee2344e414cd1283ca5e2ec3a Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Wed, 5 Aug 2026 02:32:31 -0400 Subject: [PATCH 3/4] Use manpage directives as suggested. --- .../next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst index 3260db9a2da1f9..61b9db996a7935 100644 --- a/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst +++ b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst @@ -1,2 +1,3 @@ -Do not attempt to use the ``dup3`` and ``pipe2`` system calls introduced in ++On macOS, do not attempt to use the :manpage:`dup3(2)` and ++:manpage:`pipe2(2)` system calls introduced in macOS 27 to prevent problems when running on older systems. From f38e5c317cbeff90fc100899bc6bfa19233e768d Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Wed, 5 Aug 2026 02:54:58 -0400 Subject: [PATCH 4/4] Haste makes waste --- .../next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst index 61b9db996a7935..90804c179a4b4a 100644 --- a/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst +++ b/Misc/NEWS.d/next/macOS/2026-08-05-02-02-33.gh-issue-153711.pO9fFb.rst @@ -1,3 +1,3 @@ -+On macOS, do not attempt to use the :manpage:`dup3(2)` and -+:manpage:`pipe2(2)` system calls introduced in +On macOS, do not attempt to use the :manpage:`dup3(2)` and +:manpage:`pipe2(2)` system calls introduced in macOS 27 to prevent problems when running on older systems.