HAVE_PIPE2 at compile time but not at runtime causes segfault on macOS
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
研究方向
Start in the process package's configure checks for pipe2 and do_spawn_fork, where the issue shows the conditional call. Read the autoconf feature detection and the process tests for spawn behavior on macOS. Reproduce with SDK 27 on macOS 26, then confirm process creation succeeds when pipe2 is unavailable at runtime.
由索引模型根據 Issue 內容生成。
描述
Process determines -DHAVE_PIPE2 using autoconf's AC_CHECK_FUNCS(... pipe2 ...). When at compile time HAVE_PIPE2 is available, process's do_spawn_fork will call pipe2 at runtime:
#if defined(HAVE_PIPE2)
r = pipe2(forkCommunicationFds, O_CLOEXEC);
#else
r = pipe(forkCommunicationFds);
#endif
It's common to upgrade the macOS toolchain before the OS. Most recently, that's the compilation toolchain from SDK 27 running on macOS version 26.
macOS introduced pipe2 in SDK 27, but macOS 26's system library doesn't have pipe2 yet. Long story short, if you compile this trivial program that depends on a process compiled using SDK 27, running it on macOS26 segfaults:
import System.Process
main :: IO ()
main = do
(_, _, _, ph) <- createProcess (proc "true" []) { close_fds = True }
print =<< waitForProcess ph
with this cabal.project to force process to be recompiled (instead of using the distributed one):
packages: .
constraints: process source
allow-boot-library-installs: True
the result:
cabal --store-dir=$(mktemp -d) build -w $GHC
Build profile: -w ghc-9.14.2 -O1
In order, the following will be built (use -v for more details):
- process-1.6.30.0 (lib) (requires build)
- repro-0 (exe:repro) (configuration changed)
Starting process-1.6.30.0 (lib)
configure: ...
checking for gcc... /usr/bin/gcc
...
checking for pipe2... yes <-------- !!!!!!
...
configure: creating ./config.status
Building process-1.6.30.0 (lib)
Installing process-1.6.30.0 (lib)
Completed process-1.6.30.0 (lib)
Configuring executable 'repro' for repro-0...
Preprocessing executable 'repro' for repro-0...
Building executable 'repro' for repro-0...
[2 of 2] Linking dist-newstyle/build/aarch64-osx/ghc-9.14.2/repro-0/x/repro/build/repro/repro [Library changed]
❯ dist-newstyle/build/aarch64-osx/ghc-9.14.2/repro-0/x/repro/build/repro/repro
zsh: segmentation fault dist-newstyle/build/aarch64-osx/ghc-9.14.2/repro-0/x/repro/build/repro/repro
with
❯ env -i /usr/bin/xcrun --show-sdk-version
27.2
❯ sw_vers
ProductVersion: 26.7.3
where my $GHC is 9.14.2 installed from the released bindist.
Witness the trail of destruction:
- 主要語言
- Haskell
- 星號
- 91
- 分支
- 93
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
haskell/process 的其他 Issue
-
bug
難度 4/5 3-5 天 新手友好度 48/100
-
posix_spawn falls back to fork() when create_group = True due to HAVE_DECL_ macro mismatch可能已有人在做 @lei-jia-xing 於 11 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 55/100
-
難度 4/5 3-5 天 新手友好度 57/100
-
難度 4/5 3-5 天 新手友好度 48/100
-
FreeBSD 15.1 and lower have a linker bug that affects process可能已有人在做 @luite 於 43 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 35/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
haskell/bytestring#730 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 84/100
seal-harness/seal-harness#399 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 65/100
fmidue/codeworld-tasks#124 ·
-
難度 2/5 1-3 小時 新手友好度 62/100
reflex-frp/reflex#563 ·