Bug #69998 [Fbk->Opn]: curl multi leaking memory

From: Date: Thu, 09 Jul 2015 11:33:56 +0000
Subject: Bug #69998 [Fbk->Opn]: curl multi leaking memory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194250@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69998&edit=1 ID: 69998 User updated by: fred_brownuk at yahoo dot co dot uk Reported by: fred_brownuk at yahoo dot co dot uk Summary: curl multi leaking memory -Status: Feedback +Status: Open Type: Bug Package: cURL related Operating System: Mint 17.1 & Debian 6 LTS PHP Version: 7.0.0alpha2 Block user comment: N Private report: N New Comment: Thanks for looking. Sorry this doesn't mean much to me, but here you go. ==15597== Memcheck, a memory error detector ==15597== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==15597== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info ==15597== Command: curlphpalpha2/bin/php bug69998.php ==15597== ==15597== Conditional jump or move depends on uninitialised value(s) ==15597== at 0x5ACD79: curl_compare_resources (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x8AC3B4: zend_llist_del_element (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x5AD01F: zif_curl_multi_remove_handle (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x90C5AC: ZEND_DO_ICALL_SPEC_HANDLER (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x8FCFEA: execute_ex (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x95BFC2: zend_execute (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x8BA22D: zend_execute_scripts (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x851B4F: php_execute_script (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x95D822: do_cli (in /home/fred/curlphpalpha2/bin/php) ==15597== by 0x43C1FA: main (in /home/fred/curlphpalpha2/bin/php) ==15597== resource(5) of type (curl) resource(5) of type (curl) 354976 355320 355344 355368 355392 356056 356080 356104 356128 356152 ==15597== ==15597== HEAP SUMMARY: ==15597== in use at exit: 1,030 bytes in 22 blocks ==15597== total heap usage: 32,419 allocs, 32,397 frees, 3,405,857 bytes allocated ==15597== ==15597== LEAK SUMMARY: ==15597== definitely lost: 0 bytes in 0 blocks ==15597== indirectly lost: 0 bytes in 0 blocks ==15597== possibly lost: 0 bytes in 0 blocks ==15597== still reachable: 1,030 bytes in 22 blocks ==15597== suppressed: 0 bytes in 0 blocks ==15597== Reachable blocks (those to which a pointer was found) are not shown. ==15597== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==15597== ==15597== For counts of detected and suppressed errors, rerun with: -v ==15597== Use --track-origins=yes to see where uninitialised values come from ==15597== ERROR SUMMARY: 11 errors from 1 contexts (suppressed: 0 from 0) Previous Comments: ------------------------------------------------------------------------ [2015-07-09 11:08:13] kalle@php.net Can you confirm this leak with a valgrind output or similar? valgrind --leak-check=yes php bug69998.php should be sufficient to confirm this ------------------------------------------------------------------------ [2015-07-05 22:56:16] fred_brownuk at yahoo dot co dot uk Description: ------------ On both 7.0.0alpha1 and 7.0.0alpha2 the curl multi interface is holding onto resources. A curl handle added to a multi handle with curl_multi_add_handle() should be fully independent once released from the multi handle with curl_multi_remove_handle(). Curl handles are not being released properly. Repeated use of the multi interface is leaking memory. Test script: --------------- // curl multi holding onto curl handles $mh=curl_multi_init(); $ch = curl_init(); curl_multi_add_handle($mh, $ch); curl_multi_remove_handle($mh, $ch); var_dump($ch); curl_close($ch); var_dump($ch); curl_multi_close($mh); // show memory leak for ($l=0; $l<10; $l++) { $mh=curl_multi_init(); $ch = curl_init(); curl_multi_add_handle($mh, $ch); curl_multi_remove_handle($mh, $ch); curl_close($ch); curl_multi_close($mh); echo memory_get_usage().PHP_EOL; } Expected result: ---------------- resource(5) of type (curl) resource(5) of type (Unknown) 374192 374192 374192 374192 374192 374192 374192 374192 374192 374192 Actual result: -------------- resource(5) of type (curl) resource(5) of type (curl) 374192 374536 374560 374584 374608 375272 375296 375320 375344 375368 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69998&edit=1

« previous php.bugs (#194250) next »