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

Environment details

  • OS: Debian Bullseye
  • PHP version: 8.3
  • Package name and version: google/gax:v1.34.1 (1.34.0 was working without errors)

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)
    ]
}

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 27
  • Comments: 19 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Any plans to fix it for PHP 8.3 - 8.4?

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.

I found the solution Friends!!! (google ads php) you need add "->withTransport(‘rest’) "

This is not a solution, but a workaround. You’re using REST instead of gRPC. There’s nothing wrong with doing that, but it isn’t a proper solution.

We’ve now fixed it by adding a retry mechanism in case of a Throwable error

Again not a fix, but a workaround. You’re now catching the error and retrying it, and as it’s intermittent, it seems to work.

I’ll keep investigating here.

@krystianlaubach I’ve posted the issue to the grpc repo here: https://github.com/grpc/grpc/issues/39509

Will try to take a look. In the meantime, has anyone tried this with the latest gRPC version (at this time, 1.72)?

I found the solution Friends!!! (google ads php)

return (new GoogleAdsClientBuilder()) ->withOAuth2Credential($oAuth2Credential) ->fromFile(storage_path(‘google/google_ads_php.ini’)) ->withTransport(‘rest’) ->build();

you need add "->withTransport(‘rest’) "

This issue Segmentation Fault in 1.68.0 for PHP 8.3 states: Works with grpc 1.66 and that seems to be the case. So if you have the possibility to (downgrade to) using 1.66.0 it can also be used as a workaround