googleapis / gax-php

Google API Extensions for PHP
http://googleapis.github.io/gax-php/
BSD 3-Clause "New" or "Revised" License
240 stars 53 forks source link

[1.34.1] Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? #584

Open czoIg opened 2 months ago

czoIg commented 2 months ago

Environment details

Steps to reproduce

  1. Error seems a little random, but occurs always at the same place. I couldn't reproduce it myself, because for many thousands requests, there's like 5-10 errors per day.

Code example

Exception trace

{
    "class": "Error",
    "message": "Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?",
    "code": 0,
    "file": "/app/vendor/google/gax/src/CredentialsWrapper.php:247",
    "trace": [
        "/app/vendor/grpc/grpc/src/lib/UnaryCall.php:43",
        "/app/vendor/grpc/grpc/src/lib/BaseStub.php:295",
        "/app/vendor/grpc/grpc/src/lib/BaseStub.php:545",
        "/app/vendor/google/gax/src/Transport/GrpcTransport.php:228",
        "/app/vendor/google/gax/src/GapicClientTrait.php:641",
        "/app/vendor/google/gax/src/Middleware/CredentialsWrapperMiddleware.php:58",
        "/app/vendor/google/gax/src/Middleware/FixedHeaderMiddleware.php:68",
        "/app/vendor/google/gax/src/Middleware/RetryMiddleware.php:89",
        "/app/vendor/google/gax/src/Middleware/RequestAutoPopulationMiddleware.php:73",
        "/app/vendor/google/gax/src/Middleware/OptionsFilterMiddleware.php:61",
        "/app/vendor/google/gax/src/GapicClientTrait.php:606",
        "/app/vendor/google/cloud-pubsub/src/V1/Gapic/PublisherGapicClient.php:909",
        "/app/vendor/google/cloud-core/src/ExponentialBackoff.php:97",
        "/app/vendor/google/cloud-core/src/GrpcRequestWrapper.php:135",
        "/app/vendor/google/cloud-core/src/GrpcTrait.php:81",
        "/app/vendor/google/cloud-pubsub/src/Connection/Grpc.php:284",
        "/app/vendor/google/cloud-pubsub/src/Topic.php:527",
        "/app/vendor/google/cloud-pubsub/src/Topic.php:482",
        ... (app-specific trace)
    ]
}
pulzarraider commented 2 months ago

We also encountered this problem. PHP 8.3 has new feature and tries to detect the recursion. This feature likely doesn't work correctly with the gRPC PHP extension.

The workaround is to disable stack size checks in the PHP INI settings: zend.max_allowed_stack_size: -1.

jhoffland commented 2 months ago

We also encounter this issue, incidentally. The possibility of disabling the stack size check, and avoiding the occurrence of the Error, does not mean the code works properly/efficiently. The comment in CredentialsWrapper::getAuthorizationHeaderCallback, where our infinite recursion errors originate, also suggests awareness about error-prone logic.

romanstingler commented 2 months ago

Happens thousands of times per day on my side.

hydrapolic commented 4 weeks ago

Same issue here, happens with gax 1.34.[01] on php 8.3 with swoole/grpc.

Jakoffe commented 2 weeks ago

Still an issue with gax 1.35.0 on php 8.3