php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73318 curling HTTPS URL in pcntl_fork child causes crash
Submitted: 2016-10-13 23:15 UTC Modified: 2016-10-20 22:15 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: dougnelson at silktide dot com Assigned:
Status: Closed Package: cURL related
PHP Version: 7.0.12 OS: MacOS + Linux (confirmed)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dougnelson at silktide dot com
New email:
PHP Version: OS:

 

 [2016-10-13 23:15 UTC] dougnelson at silktide dot com
Description:
------------
Steps: 

1. curl a HTTPS URL
2. run pcntl_fork
3. have the child process curl another HTTPS url
4. check the status of the child process, it will have crashed

This has been discussed here:
http://stackoverflow.com/questions/34901910/curl-and-pcntl-fork

And in a different guise here:
http://stackoverflow.com/questions/15466809/libcurl-ssl-error-after-fork?lq=1

The answer from the second link implies that it's a known issue when forking with libcurl, and the way to get around it is to call `curl_global_cleanup` pre-forking, a function that doesn't seem to have a PHP function wrapper.

Is this functionality intentionally not exposed through the PHP interface, or is it something that can be added (with the only trauma being the addition of another function)?

Test script:
---------------
http://pastebin.com/VJNFucmH

Expected result:
----------------
d41d8cd98f00b204e9800998ecf8427e
407dfffa37092ff8017e06f071bb0f93
Array
(
    [URL] => http://php.net
    [Successful Exit] => Yes
    [Exit Code] => 0
)
eff6abf853a3b5758b1449bca208df8b
Array
(
    [URL] => https://stackoverflow.com/
    [Successful Exit] => Yes
    [Exit Code] => 0
)

Actual result:
--------------
d41d8cd98f00b204e9800998ecf8427e
407dfffa37092ff8017e06f071bb0f93
Array
(
    [URL] => http://php.net
    [Process Running] => No
    [Successful Exit] => Yes
    [Exit Code] => 0
)

Array
(
    [URL] => https://stackoverflow.com/
    [Process Running] => No
    [Successful Exit] => No
    [Exit Code] => 0
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-18 12:46 UTC] krakjoe@php.net
We believe this may have been fixed with the latest changes to OpenSSL.

Would be nice if someone could confirm and update this bug.
 [2016-10-18 18:16 UTC] dougnelson at silktide dot com
Hi Krakjoe, thanks for the response.

I'm happy to try and confirm this, but can I verify which changes to OpenSSL you're referencing?

The latest released version (OpenSSL 1.0.2j) still has this issue, or are you referring to changes that been commited but are yet to be released?
 [2016-10-19 04:02 UTC] krakjoe@php.net
I was actually talking about changes to the openssl extension, sorry that wasn't clear:

https://bugs.php.net/bug.php?id=71915

Although those commits were included in 7.0.12, so I'm not so sure this morning.

I did try to reproduce this problem on older versions of PHP, so did a few other people and we couldn't.
 [2016-10-20 18:02 UTC] dougnelson at silktide dot com
I've tried to isolate it a bit further and discovered I made a faulty assumption regarding my linux versions.

The Linux server I was testing on looks like it was only on 7.0.11. Upgrading it to 7.0.12 does indeed fix the issue.

The problem however continues on Mac. The main difference between the two seems to be that the Linux Server uses curl 7.35.0 and the Mac uses 7.43.0.

I'm currently trying to work out how to update the version of curl that php is using on Linux to see if the issue reappears on Linux if it's using the same curl version. I'll update if I have any success
 [2016-10-20 22:15 UTC] dougnelson at silktide dot com
-Status: Open +Status: Closed
 [2016-10-20 22:15 UTC] dougnelson at silktide dot com
The issue disappears from Mac when upgraded to Sierra (which also upgraded curl, which I assume is the actual reason it fixed itself).

Closing as fixed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 19:01:33 2024 UTC