Hi Pecl-dev, I am a developer for the gRPC PHP extension <https://pecl.php.net/package/grpc> and run into an issue when the extension is being used behind Apache. Are there any experts here that can help me debug this further?
The problem happens if I simply try to access a constant being provided by my extension via a PHP script served by Apache. My extension is properly loaded by a php.ini file and the first few requests to the script return correct result. But after hitting the script for a few times, the script starts to return a "Fatal error: undefined constant" for all subsequent requests. A few more observations: - The problem is not reproducible on CLI. Running from command line always return the correct result, no matter how many times the script is run. - The problem is equally reproducible if the PHP extension is being loaded by Apache, or Nginx/PHP-FPM, or even the PHP standard webserver. The "Fatal error:" happens after a few requests and persists. - Speculation: It is as if there are a few workers behind Apache, and they each return correct result the first time. Once each child worker gets a second request, the "Fatal error: undefined constant" error happens for all subsequent request /speculation. - After the failure starts happening, if I hit a page to print out phpinfo(); loaded by Apache, my Grpc extension still appears to be enabled. I prepared a docker image to reproduce the issue - Clone the repo: git clone https://github.com/stanley-cheung/grpc-php-apache-testing.git - Build the docker image: docker build -t grpc_php_testing grpc-php-apache-testing/ - Run the Apache server: docker run -it --rm --name grpc_php_instance -p 9998:80 grpc_php_testing - From another terminal, run the page: curl localhost:9998/grpc.php The first few times the script is fine: - docker:~$ curl localhost:9998/grpc.php - constant OP_SEND_CLOSE_FROM_CLIENT = 2. should be 2 But after 4-6 times and all times afterward, here's the error: - [Mon Oct 05 17:31:56.395267 2015] [:error] [pid 16] [client 172.17.42.1:45444] PHP Fatal error: Undefined constant 'Grpc\\OP_SEND_CLOSE_FROM_CLIENT' in /var/www/html/grpc.php on line 2 Am I missing some configuration? Anyone have some idea on how to debug this further? Any help will be greatly appreciated! Thanks, -Stanley