Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpClient] Fix a crash when calling CurlHttpClient::__destruct() #34287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Nov 7, 2019

Q A
Branch? 4.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

I've not identified the exact issue, but when the profiler is enabled, an HttpClient instance is created and not used, then a crash occurs when __destruct() is called because $this->mutli->handle value is 0 has this point, while curl_multi_setopt expect a resource.

This PR fixes the issue, but it's maybe not the good approach.

Reproducer: symfony/mercure-bundle#14

curl version: 7.67.0

php -v
PHP 7.3.11 (cli) (built: Oct 24 2019 11:29:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.27.1~mac-x64-non_zts73, https://blackfire.io, by Blackfire

@nicolas-grekas nicolas-grekas force-pushed the fix_CurlHttpClient_destruct branch from e9f5241 to d2c5ffd Compare November 8, 2019 08:24
@nicolas-grekas
Copy link
Member

Thank you @dunglas.

nicolas-grekas added a commit that referenced this pull request Nov 8, 2019
…struct() (dunglas)

This PR was merged into the 4.3 branch.

Discussion
----------

[HttpClient] Fix a crash when calling CurlHttpClient::__destruct()

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a

I've not identified the exact issue, but when the profiler is enabled, an HttpClient instance is created and not used, then a crash occurs when `__destruct()` is called because `$this->mutli->handle` value is `0` has this point, while `curl_multi_setopt` expect a `resource`.

This PR fixes the issue, but it's maybe not the good approach.

Reproducer: symfony/mercure-bundle#14

curl version: 7.67.0

```
php -v
PHP 7.3.11 (cli) (built: Oct 24 2019 11:29:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11, Copyright (c) 1999-2018, by Zend Technologies
    with blackfire v1.27.1~mac-x64-non_zts73, https://blackfire.io, by Blackfire
```

Commits
-------

d2c5ffd [HttpClient] Fix a crash when calling CurlHttpClient::__destruct()
@nicolas-grekas nicolas-grekas merged commit d2c5ffd into symfony:4.3 Nov 8, 2019
@dunglas dunglas deleted the fix_CurlHttpClient_destruct branch November 8, 2019 19:15
@fabpot fabpot mentioned this pull request Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants