PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » File Formats » Archive_Tar » Bug #1306

Freeze on "pear package"

Details

Submitted2004-04-28 12:52 UTC
Fromfrederic dot poeydomenge at free dot fr
Assignedvblavet
StatusBogus
PackageArchive_Tar
PHP Version4.3.4
OSLinux version 2.6.5
Roadmaps(Not assigned)

Comments

[2004-04-28 12:52 UTC] frederic dot poeydomenge at free dot fr

Description:
------------
I tried to build a package by running the command "pear package", and it freezes up in an endless loop during the creation of the archive. I have localized the loop in Archive_Tar (1.1), but I didn't figure out why it was freezing. The code is in the function _openAppend() :

if ($this->_compress_type == 'gz') {
$v_buffer = @gzread($v_temp_tar, 512);
// ----- Read the following blocks but not the last one
if (!@gzeof($v_temp_tar)) {

// START OF ENDLESS LOOP
do{
$v_binary_data = pack("a512", $v_buffer);
$this->_writeBlock($v_binary_data);
$v_buffer = @gzread($v_temp_tar, 512);
} while (!@gzeof($v_temp_tar));
// END OF ENDLESS LOOP

}
@gzclose($v_temp_tar);

$v_temp_tar is a valid "resource(90) of type (stream)"

I've tried the same command on another PHP installation (4.1.2) and it is working fine.

'../configure' '--prefix=/usr' '--with-apxs=/usr/bin/apxs' '--with-regex=php' '--with-config-file-path=/etc/php4/apache' '--disable-rpath' '--enable-memory-limit' '--disable-debug' '--with-layout=GNU' '--with-pear=/usr/share/php' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db4' '--with-iconv' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--disable-xml' '--with-expat-dir=/usr' '--enable-yp' '--with-zlib' '--without-pgsql' '--with-kerberos=/usr' '--with-openssl=/usr' '--with-exec-dir=/usr/lib/php4/libexec' '--disable-static' '--with-curl=shared,/usr' '--with-dom=shared,/usr' '--with-dom-xslt=shared,/usr' '--with-dom-exslt=shared,/usr' '--with-zlib-dir=/usr' '--with-gd=shared,/usr' '--enable-gd-native-ttf' '--with-jpeg-dir=shared,/usr' '--with-xpm-dir=shared,/usr/X11R6' '--with-png-dir=shared,/usr' '--with-freetype-dir=shared,/usr' '--with-imap=shared,/usr' '--with-imap-ssl' '--with-ldap=shared,/usr' '--with-mcal=shared,/usr' '--with-mhash=shared,/usr' '--with-mm' '--with-mysql=shared,/usr' '--with-unixODBC=shared,/usr' '--with-recode=shared,/usr' '--enable-xslt=shared' '--with-xslt-sablot=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-sybase-ct=shared,/usr' '--with-ttf=shared,/usr' '--with-t1lib=shared,/usr'

Reproduce code:
---------------
pear package package.xml

[2004-04-29 11:33 UTC] frederic dot poeydomenge at free dot fr

zlib versions :
1.1.4 for the working version (debian woody)
1.2.1 for the non-working version (debian unstable)

[2004-08-14 01:35 UTC] frank at jrware dot com

Here's a patch for Archive/Tar.php that works around the hang by using gunzip/zcat to uncompress the tar file.

No guarantees, but it's worked for me.

(paste stuff below into a file, then 'cd' to '/usr/share/php/Archive' and run 'patch < your-file')

--- Tar.php.orig 2004-08-13 17:43:23.000000000 -0700
+++ Tar.php 2004-08-13 18:29:30.000000000 -0700
@@ -524,6 +524,22 @@
// {{{ _openRead()
function _openRead()
{
+ if ($this->_compress_type == 'gz') {
+ $output_lines = array ();
+ $new_tar_name = substr ($this->_tarname, 0, strrpos ($this->_tarname, ".tgz")) . ".tar";
+
+ $output_line = exec ("zcat $this->_tarname > $new_tar_name", $output_lines, $exit_status);
+
+ if ($exit_status != 0) {
+ $this->_error('Unable to gunzip \''.$this->_tarname.'\': $output_line');
+ $this->_temp_tarname = '';
+ return false;
+ }
+ $this->_tarname = $new_tar_name;
+ $this->_compress = false;
+ $this->_compress_type = 'none';
+ }
+
if (strtolower(substr($this->_tarname, 0, 7)) == 'http://') {

// ----- Look if a local copy need to be done