#41451 [Opn->Fbk]: Segmentation core dump glibc detected *** free(): invalid next size
| From: | johannes@php.net | Date: | Sun, 20 May 2007 21:29:49 +0000 |
| Subject: | #41451 [Opn->Fbk]: Segmentation core dump glibc detected *** free(): invalid next size | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-112882@lists.php.net to get a copy of this message | ||
ID: 41451
Updated by: johannes@php.net
Reported By: farayi dot nyamadzawo at unodc dot org
-Status: Open
+Status: Feedback
Bug Type: Filesystem function related
Operating System: Redhat
PHP Version: 5.2.2
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
I wasn't able to reproduce your problem using your function with either
a local file, an file from an ftp server or from an http site. If the
problem still exists with a current snapshot please give more
information what kind of file you're trying to transfer and a gdb
backtrace. Thanks.
Previous Comments:
------------------------------------------------------------------------
[2007-05-20 18:29:38] farayi dot nyamadzawo at unodc dot org
The following function also gives a error
*** glibc detected *** free(): invalid next size (normal): 0x00632898
***
function upload_file_from_url($filename, $url, $dir = 'transfer/docs/',
$overwrite_uid = false)
{
//ver. 2.0
if($fp = fopen($url,"rb")) //file exists
{
//generate UNQ name
$filename = $filename;
$filetype = 'application/octet-stream';
$fileinfo = pathinfo($filename);
$fname = $fileinfo['filename'];
$filedata = @file_get_contents($url);
if(!$filedata) return false;
$filesize = strlen($filedata);
if($filesize == 0)
{
return false;
}
//check file exists
$exists = true;
$i = 0;
while(file_exists($root.$dir.$fname.'.'.$fileinfo['extension']))
{
$i++;
$fname.= '-'.$i;
}
$filepath = $fname.'.'.$fileinfo['extension'];
//store file
if(!file_put_contents($root.$dir.$filepath, $filedata)) return
false;
return array('name' => $filename,'size'=>$filesize,
'path'=>
$filepath);
}
else
{
return false;
}
}
------------------------------------------------------------------------
[2007-05-20 18:14:32] farayi dot nyamadzawo at unodc dot org
Description:
------------
I am running the below script from command line.it gives me a
segmentation error when it is trying to download files and save them and
return any arraz.
I get the following error
glibc detected *** free(): invalid next size
function attached below
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-openssl
--with-zlib --enable-bcmath --enable-calendar --with-curl
--enable-dom --enable-exif --with-gd --with-jpeg-dir=/usr
--with-png-dir=/usr --with-freetype-dir=/usr --with-iconv
--enable-json --with-mysql --enable-xml --with-xsl --enable-zip
--enable-shared --with-ldap=/usr --with-mysqli --enable-mbstring
PHP 5.2.2 (cli)
Archive_Tar 1.3.2 stable
Console_Getopt 1.2.2 stable
DB 1.7.11 stable
PEAR 1.5.4 stable
Structures_Graph 1.0.2 stable
Reproduce code:
---------------
function upload_file_from_url($filename, $url, $dir = 'transfer/docs/',
$overwrite_uid = false)
{
//ver. 2.0
//error_reporting(E_ALL);
if($fp = fopen($url,"rb")) //file exists
{
logmsg ("DEBUG:UPLOAD - open remote file.");
//generate UNQ name
$filename = $filename;
$filetype = 'application/octet-stream';
$fileinfo = pathinfo($filename);
$fname = $fileinfo['filename'];
$filedata = '';
logmsg ("DEBUG:UPLOAD - read remote file.");
while (!feof($fp)) {
$filedata .= fread($fp, 8192);
}
if(!$filedata)
{
fclose($fp);
return false;
}
logmsg ("DEBUG:UPLOAD - reading done!");
logmsg ("DEBUG:UPLOAD - check file size");
$filesize = strlen($filedata);
if($filesize == 0)
{
fclose($fp);
return false;
}
logmsg ("DEBUG:UPLOAD - size is ok:{$filesize}");
logmsg ("DEBUG:UPLOAD - check existance of filename");
//check file exists
$exists = true;
$i = 0;
while(file_exists($this->web_root.$dir.$fname.'.'.$fileinfo['extension']))
{
$i++;
$fname.= '-'.$i;
}
$filepath = $fname.'.'.$fileinfo['extension'];
logmsg ("DEBUG:UPLOAD - check name done. using - ".$filepath);
logmsg ("DEBUG:UPLOAD - copy data..");
//store file
$fpl = fopen($this->web_root.$dir.$filepath,"w");
if($fpl)
{
fwrite($fpl,$filedata,$filesize);
fclose($fpl);
}
else
{
fclose($fp);
return false;
}
fclose($fp);
logmsg ("DEBUG:UPLOAD - data copied - done.");
return array('name' => $filename,'size'=>$filesize,
'path'=>
$filepath);
}
else
{
return false;
}
}
Expected result:
----------------
download files from website , store and return array
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41451&edit=1