'aws-sdk-php + zend framework 2 skeleton => signal Segmentation fault (11)

I'm trying to use AWS S3 in my recent project built on Zend Framework 2.

Something really strange happened and I have not been able to find the solution.

I started a fresh Zend Framework 2 Skeleton application and installed aws/aws-sdk-php via composer.

A simple S3::putObject request was created:

$client = S3Client::factory(array(
        'key' => 'xxx',
        'secret' => 'xxx',
        'region' => 'xxx',
    ));

$client->putObject(array(
                'Bucket' => $bucket,
                'Key' => '/test/test.html',
                'Body' => 'This is a test' . time(),
                'ContentType' => 'text/html',
                'Acl' => CannedAcl::PUBLIC_READ
            ));

The above code works fine when I test it in PHPUnit. However when I open the browser to see result from same IndexController, Firefox just reported 'The connection was reset'. PHP doesn't throw any exceptions

I opened Apache's error log and see:

[Tue Jul 08 04:58:58 2014] [notice] child pid 33428 exit signal Segmentation fault (11)
[Tue Jul 08 04:59:15 2014] [notice] child pid 33439 exit signal Segmentation fault (11)
[Tue Jul 08 04:59:16 2014] [notice] child pid 33361 exit signal Segmentation fault (11)
[Tue Jul 08 05:02:02 2014] [notice] child pid 33452 exit signal Segmentation fault (11)
[Tue Jul 08 05:02:50 2014] [notice] child pid 33142 exit signal Segmentation fault (11)
[Tue Jul 08 05:04:34 2014] [notice] child pid 33317 exit signal Segmentation fault (11)
[Tue Jul 08 05:04:35 2014] [notice] child pid 33143 exit signal Segmentation fault (11)
[Tue Jul 08 05:06:18 2014] [notice] child pid 33522 exit signal Segmentation fault (11)
[Tue Jul 08 05:06:19 2014] [notice] child pid 33534 exit signal Segmentation fault (11)

I googled the error and found different answers to this problem but none seems to apply to me.

After trying the latest Zend Server 7 I managed to nail down the problem in Guzzle\Http\Curl\CurlMulti, seems that something happened during curl_multi_* operations. I think the problem should be PHP is in infinite loop, but how come it works fine under PHPUnit? It has nothing to do with running from CLI because I just tried curl the same URL and got:

curl: (52) Empty reply from server

So it looks like the problem still come from inside the code...

Some posts from Google stating this curl problem might because of OSX Maverick's openssl issue but I don't think I have this problem since my curl works fine with any https requests.

And my research on this problem stops here :(

aws-sdk-php has been out for quite a long while I don't believe it is the lib's fault, can it be my machine? Here is my software environment

OSX Mavericks 10.9.4
Zend Server 7 with PHP 5.5.13
curl --version
curl 7.30.0 (x86_64-apple-darwin13.0) libcurl/7.30.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz


Solution 1:[1]

I spent hours tracking down the same problem, it happens when openssl support is not built into the version of libcurl used to build the curl extension:

build.log

checking for openssl support in libcurl... no

You'll need to install curl with openssl support, e.g. using brew: brew install curl --with-openssl (--with-openssl may not be required).

Once an openssl supported libcurl is available, you'll need to add the option --with-curl to your build command, for me this was phpbrew .. --with-curl=/usr/local/opt/curl.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andrew Mackrodt