Skip to content

Fix: prevent Go runtime init in FPM master during opcache.preload#417

Merged
tudor-timcu merged 14 commits intomainfrom
fix/fpm-opcache-preload-fork-go-runtime
Apr 22, 2026
Merged

Fix: prevent Go runtime init in FPM master during opcache.preload#417
tudor-timcu merged 14 commits intomainfrom
fix/fpm-opcache-preload-fork-go-runtime

Conversation

@PopoviciMarian
Copy link
Copy Markdown
Contributor

@PopoviciMarian PopoviciMarian commented Apr 20, 2026

When opcache.preload is configured under php-fpm, the master runs a virtual RINIT for the preload script before forking workers. That used to dlopen Aikido's Go request-processor in the master, spawning Go's scheduler/GC/netpoll kernel threads there. fork() only clones the calling thread, so workers inherited a Go runtime whose internal tables pointed at threads that didn't exist in their address space.

Summary by Aikido

Security Issues: 0 Quality Issues: 0 Resolved Issues: 0

🐛 Bugfixes

  • Added IsRequestHandledInMainPid method to detect opcache.preload master RINIT.
  • Short-circuited AST, handler, and compilation paths when master handled requests.

More info

@PopoviciMarian PopoviciMarian marked this pull request as ready for review April 21, 2026 12:17
@PopoviciMarian PopoviciMarian changed the title Fix: recover Go request processor after FPM fork with preload Fix: prevent Go runtime init in FPM master during opcache.preload Apr 21, 2026
@PopoviciMarian PopoviciMarian force-pushed the fix/fpm-opcache-preload-fork-go-runtime branch from e31d338 to fa2e325 Compare April 21, 2026 14:06
Comment thread lib/php-extension/PhpLifecycle.cpp Outdated
Comment thread lib/php-extension/PhpLifecycle.cpp Outdated
@tudor-timcu tudor-timcu merged commit 2558fce into main Apr 22, 2026
39 checks passed
@tudor-timcu tudor-timcu deleted the fix/fpm-opcache-preload-fork-go-runtime branch April 22, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants