Skip to content

[Bug]: php_herd-X.X.dll causes php-cgi to crash on startup (exit code 4294967295) — all sites return 504 #1675

@Ahmad-Chebbo

Description

@Ahmad-Chebbo

Platform

Windows

Operating system version

Windows 11

System architecture

Intel (x86)

Herd Version

1.28.0

PHP Version

No response

Bug description

Bug: php_herd-X.X.dll causes php-cgi to crash on startup (exit code 4294967295) — all sites return 504

Herd version: 1.28.0
OS: Windows 11
PHP versions affected: All (7.4, 8.0, 8.1, 8.2, 8.3, 8.4)


Description

After a fresh install of Herd 1.28.0 on Windows, all sites return 504 Gateway Timeout. The Herd CLI (herd --version, herd doctor, etc.) freezes indefinitely. Changing PHP version per site via the GUI appears to work visually but does not persist after restarting Herd.


Root cause identified

The php_herd-X.X.dll extension (loaded via php.ini) causes php-cgi.exe to exit immediately with code 4294967295 (0xFFFFFFFF / -1) when spawned by the Herd Electron process.

From main.log:

[info]  [PHP] Starting PHP 84 on port 9084
[info]  Started PHP-8.4 with PID 45948
[info]  PHP-8.4 exited with code 4294967295 - PID: 45948

This crash happens on every spawn attempt. Since php-cgi never binds to port 9084, nginx cannot forward requests and returns 504.


What works vs what doesn't

Scenario Result
php-cgi.exe -b 127.0.0.1:9084 (manual, DLL enabled) Crashes immediately
php-cgi.exe -b 127.0.0.1:9084 (manual, DLL disabled) Works, port binds correctly
php-cgi.exe -m (list modules, DLL enabled) Works fine, all modules load
Herd spawning php-cgi (DLL enabled) Crashes with code 4294967295
Herd spawning php-cgi (DLL disabled) Works, sites load correctly
herd --version (DLL disabled) Freezes — herd.phar depends on the DLL

The DLL loads fine in non-FastCGI mode (-m, -v) but crashes when php-cgi is started as a FastCGI server via -b. This only happens when spawned by Herd — manual launch with identical arguments and environment variables (PHP_FCGI_CHILDREN=4, PHP_FCGI_MAX_REQUESTS=1000) also crashes.


Impact

  • All sites return 504 (php-cgi never binds to port)
  • Herd CLI completely frozen (herd.phar depends on php_herd DLL for IPC)
  • Per-site PHP version changes do not persist (CLI required to save)

Workaround

Comment out the php_herd extension in all PHP version php.ini files:

;extension = 'C:\Program Files\Herd\resources\app.asar.unpacked\resources\bin\phpherd\php_herd-8.4.dll'

Sites work after this change but the CLI and per-site PHP version switching remain broken.


Environment

  • CPU: AMD64 Family 25 Model 68 (Ryzen)
  • Windows Defender exclusions added for both Herd folders — no change in behavior
  • Fresh install (previous installation fully removed)
  • PHP binaries location: C:\Users\<user>\.config\herd\bin\php84\
  • DLL location: C:\Program Files\Herd\resources\app.asar.unpacked\resources\bin\phpherd\

Steps to reproduce

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions