-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update php_dns.h - fixes memory leak. #1736
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
Conversation
You need to call res_ndestroy() to free memory, otherwise you will leak a file descriptor on NetBSD or leak memory on FreeBSD and other operating systems. Please see the resolver man page at: http://man.netbsd.org/cgi-bin/man-cgi?resolver++NetBSD-current "res_ndestroy() should be called to free memory allocated by res_ninit() after last use.". I found the bug on NetBSD 7.0 with php 7.0.2, but it also affects php 5.6.14 and probably previous versions. Here is a test-script to reproduce the memory leak: <?php for ($i = 0; $i < 50000; $i++) { echo $i . ": "; var_dump(checkdnsrr("www.netbsd.org", "A")); } While running this script, have a look how the php process grows because of the memory leak.
The Travis build fails to compile due to an undefined |
I see. Not all res_n* functions are implemented in Linux. We need a feature test then for res_ndestroy. This also means that it leaks only on platforms that implement res_ndestroy. (All *BSD's, Illumos (Solaris) and MacOS). |
@zaydogan any progress on this? I could test on FreeBSD once it's implemented. Thanks. |
@zaydogan bump .... some action would be good ;) |
Hello !
As mentioned before, the problem only appears on platforms that implement
res_ndestroy,
or res_n* functions like NetBSD or FreeBSD.
NetBSD has fixed it in their pkgsrc software repository.
Please have a look here:
http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/php70/patches/patch-ext_standard_php__dns.h?rev=1.1&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
Cheers!
2017-01-01 17:20 GMT+01:00 Joe Watkins <notifications@github.com>:
… @zaydogan <https://github.com/zaydogan> bump .... some action would be
good ;)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1736 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ANN2pw71c723CJIR6HPCpPP4Hnvbmt4zks5rN9I0gaJpZM4HKHGS>
.
|
@zaydogan Any reason why the patch hasn't been prepared to implement change for those operating systems only ? |
Hi,
I think my patch did not went through the automatic build system.
Also the build system is linux, maybe that's why it didn't work in the
first place.
I don't know how to "#ifdef" the code to work only for the mentioned
platforms.
2017-01-01 19:24 GMT+01:00 Joe Watkins <notifications@github.com>:
… @zaydogan <https://github.com/zaydogan> Any reason why the patch hasn't
been prepared to implement change for those operating systems only ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1736 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ANN2pw4GtsFEQ1NMzWABiS3HqhU2UMwuks5rN-9mgaJpZM4HKHGS>
.
|
@weltling can I request that you pick this up please ? |
@krakjoe noted, thanks for the ping. |
This fixes leak issues on *BSD systems, as described in the PR.
* PHP-7.0: Implement github PR #1736
* PHP-7.1: Implement github PR #1736
You need to call res_ndestroy() to free memory, otherwise you will leak a file descriptor on NetBSD or leak memory on FreeBSD and other operating systems. Please see the resolver man page at: http://man.netbsd.org/cgi-bin/man-cgi?resolver++NetBSD-current
"res_ndestroy() should be called to free memory allocated by res_ninit() after last use.".
I found the bug on NetBSD 7.0 with php 7.0.2, but it also affects php 5.6.14 and probably previous versions.
Here is a test-script to reproduce the memory leak: