|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2006-08-09 05:49 UTC] asubstitute at gmail dot com
 Description:
------------
When I run "php /www/curltest.php" I see a Segmentation Fault. If I put "echo $this->responseData" before the call to curl_close, I see the response data. If I remove the call to curl_close, the script segfaults at the end, due to curl_close being called automatically.
cURL was compiled from the newest tarball. This bug exists in the 5.2 snapshot too.
php -v : PHP 5.1.4 (cgi-fcgi) (built: Aug  9 2006 00:24:52)
Reproduce code:
---------------
class curlTest {
	function __construct($url) {
		$this->responseData = null;
		$this->responseError = false;
		$this->curl = curl_init();
		curl_setopt($this->curl, CURLOPT_URL, $url);		
	}
	function makeRequest() {
		$this->responseData = curl_exec($this->curl);
		curl_close($this->curl);
	}
}
$interface = new curlTest("http://www.google.com/explanation.html");
$interface->makeRequest();
Expected result:
----------------
Nothing
Actual result:
--------------
Segmentation Fault
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 09:00:01 2025 UTC | 
==backtrace== (gdb) bt #0 0x0056a008 in SSL_SESSION_hash () from /lib/libssl.so.4 #1 0x004311c4 in lh_free () from /lib/libcrypto.so.4 #2 0x00431333 in lh_delete () from /lib/libcrypto.so.4 #3 0x0056e131 in SSL_CTX_get_timeout () from /lib/libssl.so.4 #4 0x004312ae in lh_retrieve () from /lib/libcrypto.so.4 #5 0x0056e1e7 in SSL_CTX_flush_sessions () from /lib/libssl.so.4 #6 0x0056a192 in SSL_CTX_free () from /lib/libssl.so.4 #7 0x002a6fbd in Curl_ossl_close (conn=0x98d2f98) at ssluse.c:724 #8 0x002b6489 in Curl_ssl_close (conn=0x98d2f98) at sslgen.c:381 #9 0x002a1281 in Curl_disconnect (conn=0x98d2f98) at url.c:1634 #10 0x002a26f7 in ConnectionKillOne (data=0x98d5d70) at url.c:1835 #11 0x002a2743 in Curl_close (data=0x98d5d70) at url.c:203 #12 0x002af8f9 in curl_easy_cleanup (curl=0x98d5d70) at easy.c:485 #13 0x080dc1b5 in _php_curl_close (rsrc=0x98cce44) at /home/rixth/php-5.1.4/ext/curl/interface.c:1736 #14 0x08291da1 in list_entry_destructor (ptr=0x98cce44) at /home/rixth/php-5.1.4/Zend/zend_list.c:184 #15 0x0828f484 in zend_hash_del_key_or_index (ht=0x86ab080, arKey=0x0, nKeyLength=0, h=1, flag=1) at /home/rixth/php-5.1.4/Zend/zend_hash.c:492 #16 0x08291b3c in _zend_list_delete (id=1) at /home/rixth/php-5.1.4/Zend/zend_list.c:58 #17 0x080dc192 in zif_curl_close (ht=1, return_value=0x98cc81c, return_value_ptr=0x0, this_ptr=0x0, return_value_used=0) at /home/rixth/php-5.1.4/ext/curl/interface.c:1721 #18 0x082a22d1 in zend_do_fcall_common_helper_SPEC (execute_data=0xbff2c2d0) at /home/rixth/php-5.1.4/Zend/zend_vm_execute.h:200 #19 0x082a1c3d in execute (op_array=0x98ce404) at /home/rixth/php-5.1.4/Zend/zend_vm_execute.h:92 #20 0x082a1e91 in zend_do_fcall_common_helper_SPEC (execute_data=0xbff2c490) at /home/rixth/php-5.1.4/Zend/zend_vm_execute.h:234 #21 0x082a1c3d in execute (op_array=0x98c83c4) at /home/rixth/php-5.1.4/Zend/zend_vm_execute.h:92 #22 0x08287b76 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/rixth/php-5.1.4/Zend/zend.c:1109 #23 0x0824e838 in php_execute_script (primary_file=0xbff30be0) at /home/rixth/php-5.1.4/main/main.c:1732 #24 0x0830fa44 in main (argc=2, argv=0xbff30cb4) at /home/rixth/php-5.1.4/sapi/cgi/cgi_main.c:1608 (gdb) If I use procedural code like this, it works fine. $curl = curl_init(); $curl_setopt($curl, CURLOPT_URL, "http://www.google.com/explanation.html"); $responseData = curl_exec($curl); if (curl_errno($curl)) { $responseData = null; $responseError = curl_error($curl); } else { curl_close($curl); }