From: olaf at 7val dot com Operating system: Linux PHP version: 5.1.2 PHP Bug Type: cURL related Bug description: curl_close causes segfault when accessing members in object
Description: ------------ curl_close causes a segfault when accessing a member variable after the call (see code below) when CURLOPT_RETURNTRANSFER is true and CURLOPT_HEADERFUNCTION is set to a member function. Calling curl_setopt($this->curl, CURLOPT_HEADERFUNCTION,array(&$this, 'readHeader')); again in __destruct (before curl_close) makes the segfault go away. Adding the line: zval_copy_ctor(ch->handlers->write_header->func_name); in ext/curl/interface.c line 1152 seems to fix it, but I don't know if it produces a memory leak. Reproduce code: --------------- <?php class CurlTest { var $curl; var $url; function readHeader($ch, $data) { return strlen($data); } function __construct($url) { $this->curl = curl_init($url); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curl, CURLOPT_HEADERFUNCTION, array(&$this, 'readHeader')); curl_setopt($this->curl, CURLOPT_URL, $url); $this->url = $url; } function __destruct() { if (is_resource($this->curl)) { curl_close($this->curl); } $x = $this->url; } function exec() { curl_exec($this->curl); } } $t = new CurlTest('http://www.google.de'); $t->exec(); $t = null; ?> Expected result: ---------------- No segfault Actual result: -------------- Segfault -- Edit bug report at http://bugs.php.net/?id=36813&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36813&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36813&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36813&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36813&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36813&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36813&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36813&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36813&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36813&r=support Expected behavior: http://bugs.php.net/fix.php?id=36813&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36813&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36813&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36813&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36813&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36813&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36813&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36813&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36813&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36813&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36813&r=mysqlcfg