grpcio 1.83.0 crashes on macOS with `Check failed: wakeup_fd_->ConsumeWakeup().ok()` after fork, regression from 1.82.1
Title
grpcio 1.83.0 crashes on macOS with Check failed: wakeup_fd_->ConsumeWakeup().ok() after fork, regression from 1.82.1
Description
After upgrading from grpcio==1.82.1 to grpcio==1.83.0, our macOS build agents started crashing with a fatal check failure in the poll-based polling engine, immediately after the process forks to run a subprocess. The same code, same Python version, and same OS works fine on Linux and Windows — only macOS is affected — and reverting to grpcio==1.82.1 resolves it immediately with no other changes.
Environment
- grpcio: 1.83.0 (broken), 1.82.1 (last known good)
- OS: macOS (Apple Silicon, arm64)
- Python: 3.10.19
- Affected only on macOS; Linux and Windows builds with identical code are unaffected
Reproduction shape
Our tooling is a Python CLI that:
- Creates one or more async gRPC clients early in the process (e.g. via a Google Cloud client library using
grpc.aio), which spins up background polling threads. - Later calls
subprocess.check_output([...], cwd=some_dir)to shell out to an external command (e.g.git rev-parse HEAD).
Because cwd is passed explicitly, Python's subprocess module falls back to the classic fork()+exec() path on macOS rather than posix_spawn (which is used on Linux and avoids this entirely). The fork happens while the gRPC background threads from step 1 are still alive/polling.
With grpcio 1.82.1 this is harmless. With grpcio 1.83.0, the child process reliably crashes.
Observed log output (sanitized)
+ python -V
Python 3.10.19
...
tool - [INFO] No secrets cache found, creating now.
tool - [DEBUG] Using selector: KqueueSelector
tool - [DEBUG] [_cygrpc] Loaded running loop: id(loop)=<addr>
tool - [DEBUG] Using AsyncIOEngine.POLLER as I/O engine
...
I <ts> <pid> fork_posix.cc:71] Other threads are currently calling into gRPC, skipping fork() handlers
I <ts> <pid> ev_poll_posix.cc:593] FD from fork parent still in poll list: fd(14, generation: 1)
...
F <ts> <pid> ev_poll_posix.cc:659] Check failed: wakeup_fd_->ConsumeWakeup().ok()
...
tool - [ERROR] Error trying to get the latest revision of <repo>, quitting. Detailed error:
tool - [ERROR] ['git', '-C', '<path>', 'rev-parse', 'HEAD']
tool - [ERROR] Exception raised while executing pre_generation: 1The fork_posix.cc:71 "skipping fork() handlers" message appears repeatedly (once per subprocess invocation) before the fatal ev_poll_posix.cc:659 check failure kills the child, corrupting the output of the subprocess call and causing the parent tool to fail as if the subprocess itself had failed.
Expected behavior
grpcio should either:
- survive a
fork()in a process with live async/polling gRPC clients on macOS (as it apparently did through 1.82.1), or - fail gracefully/predictably rather than a fatal
CHECKcrash that takes down the child process.
Actual behavior
Fatal crash (F log level / abort) in ev_poll_posix.cc:659, Check failed: wakeup_fd_->ConsumeWakeup().ok(), specific to grpcio 1.83.0 on macOS.
Additional notes
- We have not yet bisected which specific commit between 1.82.1 and 1.83.0 introduced this; happy to help bisect if pointed at candidate PRs touching
ev_poll_posix.ccor fork-handling (fork_posix.cc) for macOS. - Workaround: we've pinned back to
grpcio==1.82.1for now.
Source: grpc/grpc