php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57278 runkit 0.9 do not compile with PHP 5.1.6
Submitted: 2006-10-04 07:13 UTC Modified: 2013-02-25 19:06 UTC
From: info at wiredtek dot info Assigned:
Status: Not a bug Package: runkit (PECL)
PHP Version: 5.1.6 OS: Gentoo/Linux
Private report: No CVE-ID: None
 [2006-10-04 07:13 UTC] info at wiredtek dot info
Description:
------------
The last runkit release (0.9) do not compile against PHP 
5.1.6, here the error:

gcc -I. -I/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9 -DPHP_ATOM_INC -I/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/include -I/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/main -I/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9 -I/usr/lib/php5/include/php -I/usr/lib/php5/include/php/main -I/usr/lib/php5/include/php/TSRM -I/usr/lib/php5/include/php/Zend -I/usr/lib/php5/include/php/ext -DHAVE_CONFIG_H -march=athlon-mp -O2 -pipe -fno-ident -fomit-frame-pointer -momit-leaf-frame-pointer -fforce-addr -fweb -ftracer -c /var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c  -fPIC -DPIC -o .libs/runkit_sandbox.o
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_active_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1557: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_parent_access_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1558: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_parent_read_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1559: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_parent_write_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1560: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_parent_eval_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1561: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_parent_include_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1562: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_parent_echo_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1563: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_parent_call_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1564: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
In function 'php_runkit_sandbox_parent_die_getter':
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1565: 
error: invalid lvalue in assignment
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c: 
At top level:
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1575: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1578: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1579: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1580: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1581: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1582: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1583: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1584: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1585: 
warning: initialization from incompatible pointer type
/var/tmp/portage/pecl-runkit-0.9-r2/work/runkit-0.9/runkit_sandbox.c:1586: 
warning: initialization from incompatible pointer type
make: *** [runkit_sandbox.lo] Error 1

ALWAYS REPRODUCIBLE: happen on 5 machines, both x86 32bit 
and x86 64bit (all the machines have the same 
configuration).

i can succefuly compile a lot of other PECL, so i don't 
think is a problem related to my environment 
configuration; however here below there are some useful 
infos about my environment:

System uname: 2.6.18-gentoo i686 AMD Athlon(tm) MP 1900+
Gentoo Base System version 1.12.5
Last Sync: Sun, 01 Oct 2006 14:30:08 +0000
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.3.7, 2.0.30
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 
1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.17
sys-devel/gcc-config: 1.3.13-r3
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r1
ACCEPT_KEYWORDS="x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=athlon-mp -O2 -pipe -fno-ident -fomit-frame-pointer -momit-leaf-frame-pointer -fforce-addr -fweb -ftracer"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="-march=athlon-mp -O2 -pipe -fno-ident -fomit-frame-pointer -momit-leaf-frame-pointer -fforce-addr -fweb -ftracer"
LDFLAGS="-Wl,--as-needed"
LINGUAS="it"
MAKEOPTS="-j3 -s"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-04 07:17 UTC] info at wiredtek dot info
other useful infos:

php -v
PHP 5.1.6-pl4-gentoo with Hardening-Patch 0.4.15 (cli) 
(built: Oct  2 2006 19:00:21)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend 
Technologies


php -m
bz2
calendar
date
dba
dom
exif
filter
ftp
gd
gettext
http
iconv
imap
ldap
libxml
mbstring
mcrypt
mhash
mysql
mysqli
ncurses
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_sqlite
pgsql
posix
readline
Reflection
runkit
session
SimpleXML
soap
sockets
SPL
SQLite
standard
varfilter
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

p.s.: it is not related to the CFLAGS/CXXFLAGS because the 
problem happen also with CFLAGS/CXXFLAGS = "-O1"
 [2006-10-04 09:58 UTC] info at wiredtek dot info
the same problem apply also to version 0.8
 [2006-12-07 10:56 UTC] info at wiredtek dot info
after more further testing i have discovered that the PECL 
compile fine with gcc3.x, but fail with gcc4.

the problem is always reproducible, and actualy, quite all 
the Linux distros use gcc4 as default compiler, making 
impossible to use/test PECL::runkit.

as soon as possible the source code must be changed to let 
gcc4 compile correctly the pecl, thank you.
 [2007-04-13 10:52 UTC] kernel at tekno-soft dot it
Since the runkit doesn't compile against the gcc4
with php-5.1.x, I patched it in order to get it compiled,
so below there's my current working patch.

--- runkit_sandbox.c.orig  2006-06-06 23:06:08.000000000 +0200
+++ runkit_sandbox.c    2007-04-13 16:24:48.000000000 +0200
@@ -1467,8 +1467,7 @@
        zval *retval; \
 \
        ALLOC_ZVAL(retval); \
-       Z_TYPE_P(retval) = IS_BOOL; \
-       Z_BVAL_P(retval) = objval->name; \
+       ZVAL_BOOL(retval, objval->name); \
        retval->refcount = 0; \
        retval->is_ref = 0; \
 \
 [2008-05-12 12:30 UTC] pahan at hubbitus dot spb dot su
And it is not compile again in recent snapshots of PHP 5.3.0

This patch fix it for me:
diff -NaurEbBH php-pecl-runkit-0.9.ORIG/runkit/runkit_sandbox.c php-pecl-runkit-0.9.WORK/runkit/runkit_sandbox.c
--- php-pecl-runkit-0.9.ORIG/runkit/runkit_sandbox.c	2006-11-28 15:31:26.000000000 +0300
+++ php-pecl-runkit-0.9.WORK/runkit/runkit_sandbox.c	2008-05-12 19:15:56.000000000 +0400
@@ -471,7 +471,7 @@
 						op_array = zend_compile_file(&file_handle, type TSRMLS_CC);
 						zend_destroy_file_handle(&file_handle TSRMLS_CC);
 					} else {
-						zend_file_handle_dtor(&file_handle);
+						zend_file_handle_dtor(&file_handle TSRMLS_CC);
 						RETVAL_TRUE;
 						already_included = 1;
 					}
@@ -730,7 +730,7 @@
 		/* ZE expects refcount == 0 for unowned values */
 		INIT_PZVAL(return_value);
 		PHP_SANDBOX_CROSS_SCOPE_ZVAL_COPY_CTOR(return_value);
-		return_value->refcount--;
+		Z_DELREF_P(return_value);
 
 		return return_value;
 	} else {
@@ -803,7 +803,7 @@
 		member_copy = *member;
 		member = &member_copy;
 		zval_copy_ctor(member);
-		member->refcount = 1;
+		Z_SET_REFCOUNT(member, 1);
 		convert_to_string(member);
 	}
 
@@ -877,7 +877,7 @@
 		member_copy = *member;
 		member = &member_copy;
 		zval_copy_ctor(member);
-		member->refcount = 1;
+		Z_SET_REFCOUNT(member, 1);
 		convert_to_string(member);
 	}
 
@@ -1392,8 +1392,8 @@
 		zval callback_copy = *callback;
 
 		zval_copy_ctor(&callback_copy);
-		callback_copy.is_ref = 0;
-		callback_copy.refcount = 1;
+		Z_UNSET_ISREF(callback_copy);
+		Z_SET_REFCOUNT(callback_copy, 1);
 		callback_is_true = zval_is_true(&callback_copy);
 		zval_dtor(&callback_copy);
 	}
@@ -1413,8 +1413,8 @@
 	if (objval->output_handler && return_value_used) {
 		*return_value = *objval->output_handler;
 		zval_copy_ctor(return_value);
-		return_value->refcount = 1;
-		return_value->is_ref = 0;
+		Z_SET_REFCOUNT(return_value, 1);
+		Z_UNSET_ISREF(return_value);
 	} else {
 		RETVAL_FALSE;
 	}
@@ -1430,14 +1430,14 @@
 
 	if (callback && callback_is_true) {
 		zval *cb = callback;
-		if (callback->is_ref) {
+		if (Z_ISREF_P(callback)) {
 			MAKE_STD_ZVAL(cb);
 			*cb = *callback;
 			zval_copy_ctor(cb);
-			cb->refcount = 0;
-			cb->is_ref = 0;
+			Z_SET_REFCOUNT(cb, 0);
+			Z_UNSET_ISREF_P(cb);
 		}
-		cb->refcount++;
+		Z_ADDREF_P(cb);
 		objval->output_handler = cb;
 	}
 }
@@ -1469,10 +1469,9 @@
 	zval *retval; \
 \
 	ALLOC_ZVAL(retval); \
-	Z_TYPE_P(retval) = IS_BOOL; \
-	Z_LVAL_P(retval) = objval->name; \
-	retval->refcount = 0; \
-	retval->is_ref = 0; \
+	ZVAL_BOOL(retval, objval->name); \
+	Z_SET_REFCOUNT(retval, 0); \
+	Z_UNSET_ISREF(retval); \
 \
 	return retval; \
 }
@@ -1499,7 +1498,7 @@
 		zval_ptr_dtor(&objval->output_handler);
 	}
 
-	value->refcount++;
+	Z_ADDREF_P(value);
 	objval->output_handler = value;
 }
 
@@ -1514,7 +1513,7 @@
 	} else {
 		ZVAL_LONG(retval, objval->parent_scope);
 	}
-	retval->refcount = 0;
+	Z_SET_REFCOUNT(retval, 0);
 
 	return retval;
 }
@@ -1620,7 +1619,7 @@
 		member_copy = *member;
 		member = &member_copy;
 		zval_copy_ctor(member);
-		member->refcount = 1;
+		Z_SET_REFCOUNT(member, 1);
 		convert_to_string(member);
 	}
 
@@ -1656,7 +1655,7 @@
 		member_copy = *member;
 		member = &member_copy;
 		zval_copy_ctor(member);
-		member->refcount = 1;
+		Z_SET_REFCOUNT(member, 1);
 		convert_to_string(member);
 	}
 
@@ -1692,7 +1691,7 @@
 		member_copy = *member;
 		member = &member_copy;
 		zval_copy_ctor(member);
-		member->refcount = 1;
+		Z_SET_REFCOUNT(member, 1);
 		convert_to_string(member);
 	}
 
diff -NaurEbBH php-pecl-runkit-0.9.ORIG/runkit/runkit_sandbox_parent.c php-pecl-runkit-0.9.WORK/runkit/runkit_sandbox_parent.c
--- php-pecl-runkit-0.9.ORIG/runkit/runkit_sandbox_parent.c	2006-06-07 21:35:33.000000000 +0400
+++ php-pecl-runkit-0.9.WORK/runkit/runkit_sandbox_parent.c	2008-05-12 19:22:39.000000000 +0400
@@ -94,8 +94,8 @@
 					ALLOC_INIT_ZVAL(hidden);
 					array_init(hidden);
 					ht = Z_ARRVAL_P(hidden);
-					if ((*symtable)->refcount > 1 &&
-						!(*symtable)->is_ref) {
+					if (Z_REFCOUNT_PP(symtable) > 1 &&
+						!Z_ISREF_PP(symtable)) {
 						zval *cv;
 
 						MAKE_STD_ZVAL(cv);
@@ -105,8 +105,8 @@
 						INIT_PZVAL(cv);
 						*symtable = cv;
 					}
-					(*symtable)->is_ref = 1;
-					(*symtable)->refcount++;
+					Z_SET_ISREF_PP(symtable);
+					Z_ADDREF_PP(symtable);
 					zend_hash_update(ht, objval->self->parent_scope_name, objval->self->parent_scope_namelen + 1, (void*)symtable, sizeof(zval*), NULL);
 
 					/* Store that dummy array in the sandbox's hidden properties table so that it gets cleaned up on dtor */
@@ -278,7 +278,7 @@
 					op_array = zend_compile_file(&file_handle, type TSRMLS_CC);
 					zend_destroy_file_handle(&file_handle TSRMLS_CC);
 				} else {
-					zend_file_handle_dtor(&file_handle);
+					zend_file_handle_dtor(&file_handle TSRMLS_CC);
 					RETVAL_TRUE;
 					already_included = 1;
 				}
@@ -534,7 +534,7 @@
 		/* ZE expects refcount == 0 for unowned values */
 		INIT_PZVAL(return_value);
 		PHP_SANDBOX_CROSS_SCOPE_ZVAL_COPY_CTOR(return_value);
-		return_value->refcount--;
+		Z_DELREF_P(return_value);
 
 		return return_value;
 	} else {
@@ -607,7 +607,7 @@
 		member_copy = *member;
 		member = &member_copy;
 		zval_copy_ctor(member);
-		member->refcount = 1;
+		Z_SET_REFCOUNT_P(member, 1);
 		convert_to_string(member);
 	}
 
@@ -680,7 +680,7 @@
 		member_copy = *member;
 		member = &member_copy;
 		zval_copy_ctor(member);
-		member->refcount = 1;
+		Z_SET_REFCOUNT_P(member, 1);
 		convert_to_string(member);
 	}
 
diff -NaurEbBH php-pecl-runkit-0.9.ORIG/runkit/php_runkit.h php-pecl-runkit-0.9.WORK/runkit/php_runkit.h
--- php-pecl-runkit-0.9.ORIG/runkit/php_runkit.h	2008-03-31 14:11:36.000000000 +0400
+++ php-pecl-runkit-0.9.WORK/runkit/php_runkit.h	2008-05-12 20:05:14.000000000 +0400
@@ -261,8 +261,8 @@
 		default: \
 			zval_copy_ctor(pzv); \
 	} \
-	(pzv)->refcount = 1; \
-	(pzv)->is_ref = 0; \
+	Z_SET_REFCOUNT_P(pzv, 1); \
+	Z_UNSET_ISREF(pzv); \
 }
 #endif /* PHP_RUNKIT_SANDBOX */
 [2013-02-25 19:06 UTC] pollita@php.net
-Status: Open +Status: Not a bug
 [2013-02-25 19:06 UTC] pollita@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Builds fine against 5.1.6 using the newest patches.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Feb 18 14:01:25 2019 UTC