awslabs / aws-crt-php

Apache License 2.0
322 stars 13 forks source link

Segfault + deprecated notice emitted when trying to send use S3 headBucket #65

Closed asgrim closed 1 year ago

asgrim commented 1 year ago

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug

When calling headBucket like this:

$awsClient->headBucket(['Bucket' => $bucketName]);

We are receiving an error

Deprecated: aws_crt_sign_request_aws(): Passing null to parameter #4 ($user_data) of type int is deprecated in /var/task/vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Extension.php on line 27

This appears to be awslabs/aws-crt-php internal issue, as the null mentioned is coming from this on Line 16:

https://github.com/awslabs/aws-crt-php/blob/541b3c8952d164e0a852b38ca358e263403419d4/src/AWS/CRT/Auth/Signing.php#L12-L16

There does not appear to be a way to provide the required $user_data parameter.

SDK version number

aws/aws-crt-php                                v1.0.2             AWS Common Runtime for PHP
aws/aws-sdk-php                                3.227.0            AWS SDK for PHP - Use Amazon Web Services in your PHP project

We are building the aws/aws-crt-php extension using:

# Install the AWS CRT extension. This is required to run on AWS infrastructure
RUN git clone --recursive https://github.com/awslabs/aws-crt-php.git /aws-crt-php \
    && cd /aws-crt-php  \
    && phpize  \
    && ./configure \
    && make

# Copy the awscrt extension to a usable location in this image so that composer can run
RUN mkdir -p /opt/php/lib/php/extensions/no-debug-non-zts-20210902 && \
    cp /aws-crt-php/modules/awscrt.so /opt/php/lib/php/extensions/no-debug-non-zts-20210902

Platform/OS/Hardware/Device

AWS Lambda running a custom Docker image, with PHP 8.1 - the Dockerfile is here

To Reproduce (observed behavior)

$awsClient->headBucket(['Bucket' => $bucketName]);

Expected behavior

We expect the headBucket call to return information about the bucket.

Logs/output

Deprecated: aws_crt_sign_request_aws(): Passing null to parameter #4 ($user_data) of type int is deprecated in /var/task/vendor/aws/aws-crt-php/src/AWS/CRT/Internal/Extension.php on line 27

Note: no stack trace is displayed, and the script seems to terminate with a segfault, although we have not confirmed if this is the extension or not. I suspect if the extension does not accept null, then there may be some memory being accessed or written illegally

asgrim commented 1 year ago

Our suspicion is that this extension does not correctly work on PHP 8.1 yet - we are still seeing a segfault, and wonder if the API in PHP changed significantly enough that something in this extension is not compatible yet.

asgrim commented 1 year ago

We've tried this using PHP 8.0 instead - it removed the deprecation notice, but sadly we are still receiving the segfault when we call headBucket (as described above).

asgrim commented 1 year ago

We are working around the issue by using a bucket name instead of ARN, so that the Signature V4a is not used, and therefore the aws-crt-php extension is not required. There was definitely a segfault coming from the extension, but as we are not requiring the extension any more, I'm afraid we can't provide further information.