[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.h branches/PHP_5_3/ext/pdo_mysql/php_pdo_mys

2010-10-22 Thread Andrey Hristov
andrey   Fri, 22 Oct 2010 15:46:26 +

Revision: http://svn.php.net/viewvc?view=revision&revision=304627

Log:
profiling in trace mode

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.h
U   php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h
U   php/php-src/trunk/ext/mysqlnd/mysqlnd.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.h
U   php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c	2010-10-22 14:51:07 UTC (rev 304626)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c	2010-10-22 15:46:26 UTC (rev 304627)
@@ -2315,10 +2315,11 @@
 PHPAPI MYSQLND * _mysqlnd_init(zend_bool persistent TSRMLS_DC)
 {
 	size_t alloc_size = sizeof(MYSQLND) + mysqlnd_plugin_count() * sizeof(void *);
-	MYSQLND *ret = mnd_pecalloc(1, alloc_size, persistent);
+	MYSQLND *ret;

 	DBG_ENTER("mysqlnd_init");
 	DBG_INF_FMT("persistent=%u", persistent);
+	ret = mnd_pecalloc(1, alloc_size, persistent);
 	if (!ret) {
 		DBG_RETURN(NULL);
 	}

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c	2010-10-22 14:51:07 UTC (rev 304626)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c	2010-10-22 15:46:26 UTC (rev 304627)
@@ -27,6 +27,7 @@
 #include "mysqlnd_wireprotocol.h"
 #include "mysqlnd_statistics.h"
 #include "zend_builtin_functions.h"
+#include "inttypes.h"

 static const char * const mysqlnd_debug_default_trace_file = "/tmp/mysqlnd.trace";

@@ -287,7 +288,6 @@
 flags & MYSQLND_DEBUG_DUMP_LEVEL? level_buffer:"",
 pipe_buffer, type? type:"", buffer);
 	efree(buffer);
-
 	ret = php_stream_write(self->stream, message_line, message_line_len)? PASS:FAIL;
 	efree(message_line); /* allocated by spprintf */

@@ -307,6 +307,7 @@
 		  unsigned int line, const char * const file,
 		  const char * const func_name, unsigned int func_name_len)
 {
+	uint64_t some_time = 0;
 	if ((self->flags & MYSQLND_DEBUG_DUMP_TRACE) == 0 || self->file_name == NULL) {
 		return FALSE;
 	}
@@ -319,6 +320,7 @@
 		while (*p) {
 			if (*p == func_name) {
 zend_stack_push(&self->call_stack, "", sizeof(""));
+zend_stack_push(&self->call_time_stack, &some_time, sizeof(some_time));
 return FALSE;
 			}
 			p++;
@@ -326,6 +328,7 @@
 	}

 	zend_stack_push(&self->call_stack, func_name, func_name_len + 1);
+	zend_stack_push(&self->call_time_stack, &some_time, sizeof(some_time));

 	if (zend_hash_num_elements(&self->not_filtered_functions) &&
 		0 == zend_hash_exists(&self->not_filtered_functions, func_name, strlen(func_name) + 1))
@@ -341,9 +344,12 @@

 /* {{{ mysqlnd_res_meta::func_leave */
 static enum_func_status
-MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int line, const char * const file)
+MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int line, const char * const file, uint64_t call_time)
 {
 	char *func_name;
+	uint64_t * parent_non_own_time_ptr = NULL, * mine_non_own_time_ptr = NULL;
+	uint64_t mine_non_own_time;
+
 	if ((self->flags & MYSQLND_DEBUG_DUMP_TRACE) == 0 || self->file_name == NULL) {
 		return PASS;
 	}
@@ -353,15 +359,34 @@

 	zend_stack_top(&self->call_stack, (void **)&func_name);

+
+	zend_stack_top(&self->call_time_stack, (void **)&mine_non_own_time_ptr);
+	mine_non_own_time = *mine_non_own_time_ptr;
+	zend_stack_del_top(&self->call_time_stack); /* callee - removing ourselves */
+
 	if (func_name[0] == '\0') {
 		; /* don't log that function */
 	} else if (!zend_hash_num_elements(&self->not_filtered_functions) ||
 			   1 == zend_hash_exists(&self->not_filtered_functions, func_name, strlen(func_name) + 1))
 	{
-		self->m->log_va(self, line, file, zend_stack_count(&self->call_stack) - 1, NULL, "<%s", func_name);
+		self->m->log_va(self, line, file, zend_stack_count(&self->call_stack) - 1, NULL, "<%s (total=%u own=%u in_calls=%u)",
+		func_name, (unsigned int) call_time, (unsigned int) (call_time - mine_non_own_time), (unsigned int) mine_non_own_time
+	);
 	}

-	return zend_stack_del_top(&self->call_stack) == SUCCESS? PASS:FAIL;
+	{
+		enum_func_status ret = zend_stack_del_top(&self->call_stack) == SUCCESS? PASS:FAIL;
+		if ((uint) zend_stack_count(&self->call_time_stack)) {
+			uint64_t parent_non_own_time = 0;
+
+			zend_stack_top(&self->call_time_stack, (void **)&parent_non_own_time_ptr);
+			parent_non_own_time = *parent_non_own_time_ptr;
+			parent_non_own_time += call_time;
+			zend_stack_del_top(&self->call_time_stack); /* the caller */
+	

[PHP-CVS] svn: /php/php-src/trunk/ NEWS Zend/zend_execute.c Zend/zend_execute.h Zend/zend_vm_def.h Zend/zend_vm_execute.h

2010-10-22 Thread Dmitry Stogov
dmitry   Fri, 22 Oct 2010 14:51:07 +

Revision: http://svn.php.net/viewvc?view=revision&revision=304626

Log:
reduced size of temp_variariable

Changed paths:
U   php/php-src/trunk/NEWS
U   php/php-src/trunk/Zend/zend_execute.c
U   php/php-src/trunk/Zend/zend_execute.h
U   php/php-src/trunk/Zend/zend_vm_def.h
U   php/php-src/trunk/Zend/zend_vm_execute.h

Modified: php/php-src/trunk/NEWS
===
--- php/php-src/trunk/NEWS  2010-10-22 14:34:33 UTC (rev 304625)
+++ php/php-src/trunk/NEWS  2010-10-22 14:51:07 UTC (rev 304626)
@@ -91,6 +91,7 @@
   . the size of zend_class_entry is reduced by sharing the same memory space
 by different information for internal and user classes.
 See zend_class_inttry.info union.
+  . reduced size of temp_variariable
 - Improved CLI Interactive readline shell (Johannes)
   . Added cli.pager ini setting to set a pager for output.
   . Added cli.prompt ini settingto configure the shell prompt.

Modified: php/php-src/trunk/Zend/zend_execute.c
===
--- php/php-src/trunk/Zend/zend_execute.c   2010-10-22 14:34:33 UTC (rev 
304625)
+++ php/php-src/trunk/Zend/zend_execute.c   2010-10-22 14:51:07 UTC (rev 
304626)
@@ -1144,8 +1144,7 @@
result->str_offset.str = container;
PZVAL_LOCK(container);
result->str_offset.offset = Z_LVAL_P(dim);
-   result->var.ptr_ptr = NULL;
-   result->var.ptr = NULL;
+   result->str_offset.ptr_ptr = NULL;
return;
}
break;

Modified: php/php-src/trunk/Zend/zend_execute.h
===
--- php/php-src/trunk/Zend/zend_execute.h   2010-10-22 14:34:33 UTC (rev 
304625)
+++ php/php-src/trunk/Zend/zend_execute.h   2010-10-22 14:51:07 UTC (rev 
304626)
@@ -35,16 +35,13 @@
zend_bool fcall_returned_reference;
} var;
struct {
-   zval **ptr_ptr;
-   zval *ptr;
-   zend_bool fcall_returned_reference;
+   zval **ptr_ptr; /* shared with var.ptr_ptr */
zval *str;
zend_uint offset;
} str_offset;
struct {
-   zval **ptr_ptr;
-   zval *ptr;
-   zend_bool fcall_returned_reference;
+   zval **ptr_ptr; /* shared with var.ptr_ptr */
+   zval *ptr;  /* shared with var.ptr */
HashPointer fe_pos;
} fe;
zend_class_entry *class_entry;

Modified: php/php-src/trunk/Zend/zend_vm_def.h
===
--- php/php-src/trunk/Zend/zend_vm_def.h2010-10-22 14:34:33 UTC (rev 
304625)
+++ php/php-src/trunk/Zend/zend_vm_def.h2010-10-22 14:51:07 UTC (rev 
304626)
@@ -4039,7 +4039,7 @@
}
}

-   AI_SET_PTR(&EX_T(opline->result.var), array_ptr);
+   EX_T(opline->result.var).fe.ptr = array_ptr;

if (iter) {
iter->index = 0;
@@ -4097,7 +4097,7 @@
 {
USE_OPLINE
zend_free_op free_op1;
-   zval *array = EX_T(opline->op1.var).var.ptr;
+   zval *array = EX_T(opline->op1.var).fe.ptr;
zval **value;
char *str_key;
uint str_key_len;

Modified: php/php-src/trunk/Zend/zend_vm_execute.h
===
--- php/php-src/trunk/Zend/zend_vm_execute.h2010-10-22 14:34:33 UTC (rev 
304625)
+++ php/php-src/trunk/Zend/zend_vm_execute.h2010-10-22 14:51:07 UTC (rev 
304626)
@@ -2542,7 +2542,7 @@
}
}

-   AI_SET_PTR(&EX_T(opline->result.var), array_ptr);
+   EX_T(opline->result.var).fe.ptr = array_ptr;

if (iter) {
iter->index = 0;
@@ -6805,7 +6805,7 @@
}
}

-   AI_SET_PTR(&EX_T(opline->result.var), array_ptr);
+   EX_T(opline->result.var).fe.ptr = array_ptr;

if (iter) {
iter->index = 0;
@@ -11094,7 +11094,7 @@
}
}

-   AI_SET_PTR(&EX_T(opline->result.var), array_ptr);
+   EX_T(opline->result.var).fe.ptr = array_ptr;

if (iter) {
iter->index = 0;
@@ -11152,7 +11152,7 @@
 {
USE_OPLINE

-   zval *array = EX_T(opline->op1.var).var.ptr;
+   zval *array = EX_T(opline->op1.var).fe.ptr;
zval **value;
char *str_key;
uint str_key_len;
@@ -26765,7 +26765,7 @@
}
}

-   AI_SET_PTR(&EX_T(opline->result.var), array_ptr);
+   EX_T(opline->result.var).fe.ptr = array_ptr;

if (iter) {
iter->index = 0;

-- 
PHP CVS Mailing L

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd.h trunk/ext/mysqlnd/mysqlnd.h

2010-10-22 Thread Andrey Hristov
andrey   Fri, 22 Oct 2010 14:34:33 +

Revision: http://svn.php.net/viewvc?view=revision&revision=304625

Log:
last piece to enable trace logging on windows

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.h
U   php/php-src/trunk/ext/mysqlnd/mysqlnd.h

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.h
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.h  2010-10-22 14:21:55 UTC 
(rev 304624)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.h  2010-10-22 14:34:33 UTC 
(rev 304625)
@@ -44,7 +44,7 @@
 #define MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND 1
 #endif

-#if PHP_DEBUG && !defined(PHP_WIN32)
+#if PHP_DEBUG
 #define MYSQLND_DBG_ENABLED 1
 #else
 #define MYSQLND_DBG_ENABLED 0

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd.h
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd.h 2010-10-22 14:21:55 UTC (rev 
304624)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd.h 2010-10-22 14:34:33 UTC (rev 
304625)
@@ -44,7 +44,7 @@
 #define MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND 1
 #endif

-#if PHP_DEBUG && !defined(PHP_WIN32)
+#if PHP_DEBUG
 #define MYSQLND_DBG_ENABLED 1
 #else
 #define MYSQLND_DBG_ENABLED 0

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.h trunk/ext/mysqlnd/mysqlnd_debug.h

2010-10-22 Thread Andrey Hristov
andrey   Fri, 22 Oct 2010 14:12:45 +

Revision: http://svn.php.net/viewvc?view=revision&revision=304622

Log:
enable debug logging on windows, in debug builds, of course

Changed paths:
U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.h
U   php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.h

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.h
===
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.h2010-10-22 
14:08:30 UTC (rev 304621)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.h2010-10-22 
14:12:45 UTC (rev 304622)
@@ -63,7 +63,8 @@

 PHPAPI char *  mysqlnd_get_backtrace(uint max_levels, size_t * length 
TSRMLS_DC);

-#if defined(__GNUC__)
+/* Variadic Macros were introduced in VC 2005, which is _MSC_VER 1400 */
+#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1400)
 #define DBG_INF_EX(dbg_obj, msg)   do { if (dbg_skip_trace == 
FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "info : ", (msg)); 
} while (0)
 #define DBG_ERR_EX(dbg_obj, msg)   do { if (dbg_skip_trace == 
FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "error: ", (msg)); 
} while (0)
 #define DBG_INF_FMT_EX(dbg_obj, ...)   do { if (dbg_skip_trace == FALSE) 
(dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "info : ", 
__VA_ARGS__); } while (0)

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.h
===
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.h   2010-10-22 14:08:30 UTC 
(rev 304621)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.h   2010-10-22 14:12:45 UTC 
(rev 304622)
@@ -63,7 +63,8 @@

 PHPAPI char *  mysqlnd_get_backtrace(uint max_levels, size_t * length 
TSRMLS_DC);

-#if defined(__GNUC__)
+/* Variadic Macros were introduced in VC 2005, which is _MSC_VER 1400 */
+#if defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1400)
 #define DBG_INF_EX(dbg_obj, msg)   do { if (dbg_skip_trace == 
FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "info : ", (msg)); 
} while (0)
 #define DBG_ERR_EX(dbg_obj, msg)   do { if (dbg_skip_trace == 
FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "error: ", (msg)); 
} while (0)
 #define DBG_INF_FMT_EX(dbg_obj, ...)   do { if (dbg_skip_trace == FALSE) 
(dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "info : ", 
__VA_ARGS__); } while (0)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_execute.c zend_vm_def.h zend_vm_execute.h

2010-10-22 Thread Dmitry Stogov
dmitry   Fri, 22 Oct 2010 13:59:23 +

Revision: http://svn.php.net/viewvc?view=revision&revision=304620

Log:
Simplified foreach() handling, we don't have to inctrement/decrement refcount 
twice

Changed paths:
U   php/php-src/trunk/Zend/zend_execute.c
U   php/php-src/trunk/Zend/zend_vm_def.h
U   php/php-src/trunk/Zend/zend_vm_execute.h

Modified: php/php-src/trunk/Zend/zend_execute.c
===
--- php/php-src/trunk/Zend/zend_execute.c	2010-10-22 13:51:42 UTC (rev 304619)
+++ php/php-src/trunk/Zend/zend_execute.c	2010-10-22 13:59:23 UTC (rev 304620)
@@ -505,21 +505,6 @@
 	return get_zval_ptr(op_type, op, Ts, should_free, type);
 }

-static inline void zend_switch_free(temp_variable *T, int extended_value TSRMLS_DC)
-{
-	if (T->var.ptr) {
-		if (extended_value & ZEND_FE_RESET_VARIABLE) { /* foreach() free */
-			Z_DELREF_P(T->var.ptr);
-		}
-		zval_ptr_dtor(&T->var.ptr);
-	} else if (!T->var.ptr_ptr) {
-		/* perform the equivalent of equivalent of a
-		 * quick & silent get_zval_ptr, and FREE_OP
-		 */
-		PZVAL_UNLOCK_FREE(T->str_offset.str);
-	}
-}
-
 static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **value_ptr_ptr TSRMLS_DC)
 {
 	zval *variable_ptr = *variable_ptr_ptr;
@@ -1404,7 +1389,7 @@
 			switch (brk_opline->opcode) {
 case ZEND_SWITCH_FREE:
 	if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
-		zend_switch_free(&T(brk_opline->op1.var), brk_opline->extended_value TSRMLS_CC);
+		zval_ptr_dtor(&T(brk_opline->op1.var).var.ptr);
 	}
 	break;
 case ZEND_FREE:

Modified: php/php-src/trunk/Zend/zend_vm_def.h
===
--- php/php-src/trunk/Zend/zend_vm_def.h	2010-10-22 13:51:42 UTC (rev 304619)
+++ php/php-src/trunk/Zend/zend_vm_def.h	2010-10-22 13:59:23 UTC (rev 304620)
@@ -3212,7 +3212,7 @@
 	switch (brk_opline->opcode) {
 		case ZEND_SWITCH_FREE:
 			if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
-zend_switch_free(&EX_T(brk_opline->op1.var), brk_opline->extended_value TSRMLS_CC);
+zval_ptr_dtor(&EX_T(brk_opline->op1.var).var.ptr);
 			}
 			break;
 		case ZEND_FREE:
@@ -3247,7 +3247,7 @@
 	USE_OPLINE

 	SAVE_OPLINE();
-	zend_switch_free(&EX_T(opline->op1.var), opline->extended_value TSRMLS_CC);
+	zval_ptr_dtor(&EX_T(opline->op1.var).var.ptr);
 	CHECK_EXCEPTION();
 	ZEND_VM_NEXT_OPCODE();
 }
@@ -4030,11 +4030,7 @@
 		if (iter && EXPECTED(EG(exception) == NULL)) {
 			array_ptr = zend_iterator_wrap(iter TSRMLS_CC);
 		} else {
-			if (opline->extended_value & ZEND_FE_RESET_VARIABLE) {
-FREE_OP1_VAR_PTR();
-			} else {
-FREE_OP1_IF_VAR();
-			}
+			FREE_OP1_IF_VAR();
 			if (!EG(exception)) {
 zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name);
 			}
@@ -4043,7 +4039,6 @@
 		}
 	}

-	PZVAL_LOCK(array_ptr);
 	AI_SET_PTR(&EX_T(opline->result.var), array_ptr);

 	if (iter) {
@@ -4051,25 +4046,15 @@
 		if (iter->funcs->rewind) {
 			iter->funcs->rewind(iter TSRMLS_CC);
 			if (UNEXPECTED(EG(exception) != NULL)) {
-Z_DELREF_P(array_ptr);
 zval_ptr_dtor(&array_ptr);
-if (opline->extended_value & ZEND_FE_RESET_VARIABLE) {
-	FREE_OP1_VAR_PTR();
-} else {
-	FREE_OP1_IF_VAR();
-}
+FREE_OP1_IF_VAR();
 HANDLE_EXCEPTION();
 			}
 		}
 		is_empty = iter->funcs->valid(iter TSRMLS_CC) != SUCCESS;
 		if (UNEXPECTED(EG(exception) != NULL)) {
-			Z_DELREF_P(array_ptr);
 			zval_ptr_dtor(&array_ptr);
-			if (opline->extended_value & ZEND_FE_RESET_VARIABLE) {
-FREE_OP1_VAR_PTR();
-			} else {
-FREE_OP1_IF_VAR();
-			}
+			FREE_OP1_IF_VAR();
 			HANDLE_EXCEPTION();
 		}
 		iter->index = -1; /* will be set to 0 before using next handler */
@@ -4099,11 +4084,7 @@
 		is_empty = 1;
 	}

-	if (opline->extended_value & ZEND_FE_RESET_VARIABLE) {
-		FREE_OP1_VAR_PTR();
-	} else {
-		FREE_OP1_IF_VAR();
-	}
+	FREE_OP1_IF_VAR();
 	if (is_empty) {
 		ZEND_VM_JMP(EX(op_array)->opcodes+opline->op2.opline_num);
 	} else {
@@ -4182,7 +4163,6 @@
  * In case that ever happens we need an additional flag. */
 iter->funcs->move_forward(iter TSRMLS_CC);
 if (UNEXPECTED(EG(exception) != NULL)) {
-	Z_DELREF_P(array);
 	zval_ptr_dtor(&array);
 	HANDLE_EXCEPTION();
 }
@@ -4191,7 +4171,6 @@
 			if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
 /* reached end of iteration */
 if (UNEXPECTED(EG(exception) != NULL)) {
-	Z_DELREF_P(array);
 	zval_ptr_dtor(&array);
 	HANDLE_EXCEPTION();
 }
@@ -4199,7 +4178,6 @@
 			}
 			iter->funcs->get_current_data(iter, &value TSRMLS_CC);
 			if (UNEXPECTED(EG(exception) != NULL)) {
-Z_DELREF_P(array);
 zval_ptr_dtor(&array);
 HANDLE_EXCEPTION();
 			}
@@ -4211,7 +4189,6 @@
 if (iter->funcs->get_current_key) {
 	key_type = iter->funcs->get_current_key(iter, &str_k

[PHP-CVS] svn: /php/php-src/trunk/Zend/ tests/str_offset_002.phpt zend_vm_def.h zend_vm_execute.h

2010-10-22 Thread Dmitry Stogov
dmitry   Fri, 22 Oct 2010 11:05:22 +

Revision: http://svn.php.net/viewvc?view=revision&revision=304612

Log:
Fixed crash on attempt to insert reference to string offset into an array

Changed paths:
A   php/php-src/trunk/Zend/tests/str_offset_002.phpt
U   php/php-src/trunk/Zend/zend_vm_def.h
U   php/php-src/trunk/Zend/zend_vm_execute.h

Added: php/php-src/trunk/Zend/tests/str_offset_002.phpt
===
--- php/php-src/trunk/Zend/tests/str_offset_002.phpt	(rev 0)
+++ php/php-src/trunk/Zend/tests/str_offset_002.phpt	2010-10-22 11:05:22 UTC (rev 304612)
@@ -0,0 +1,9 @@
+--TEST--
+string offset 002
+--FILE--
+
+--EXPECTF--
+Fatal error: Cannot create references to/from string offsets in %sstr_offset_002.php on line 3

Modified: php/php-src/trunk/Zend/zend_vm_def.h
===
--- php/php-src/trunk/Zend/zend_vm_def.h	2010-10-22 10:18:31 UTC (rev 304611)
+++ php/php-src/trunk/Zend/zend_vm_def.h	2010-10-22 11:05:22 UTC (rev 304612)
@@ -3463,6 +3463,9 @@
 	if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);

+		if (OP1_TYPE == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);

Modified: php/php-src/trunk/Zend/zend_vm_execute.h
===
--- php/php-src/trunk/Zend/zend_vm_execute.h	2010-10-22 10:18:31 UTC (rev 304611)
+++ php/php-src/trunk/Zend/zend_vm_execute.h	2010-10-22 11:05:22 UTC (rev 304612)
@@ -3367,6 +3367,9 @@
 	if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = NULL;

+		if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);
@@ -4062,6 +4065,9 @@
 	if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = NULL;

+		if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);
@@ -4724,6 +4730,9 @@
 	if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = NULL;

+		if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);
@@ -5235,6 +5244,9 @@
 	if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = NULL;

+		if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);
@@ -5966,6 +5978,9 @@
 	if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = NULL;

+		if (IS_CONST == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);
@@ -7597,6 +7612,9 @@
 	if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = NULL;

+		if (IS_TMP_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);
@@ -8254,6 +8272,9 @@
 	if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = NULL;

+		if (IS_TMP_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);
@@ -8918,6 +8939,9 @@
 	if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
 		zval **expr_ptr_ptr = NULL;

+		if (IS_TMP_VAR == IS_VAR && UNEXPECTED(expr_ptr_ptr == NULL)) {
+			zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets");
+		}
 		SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr);
 		expr_ptr = *expr_ptr_ptr;
 		Z_ADDREF_P(expr_ptr);
@@ -9316,6 +9340,9 @@
 	if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR

[PHP-CVS] svn: /php/php-src/trunk/Zend/ zend_vm_def.h zend_vm_execute.h

2010-10-22 Thread Dmitry Stogov
dmitry   Fri, 22 Oct 2010 09:56:39 +

Revision: http://svn.php.net/viewvc?view=revision&revision=304609

Log:
Removed redundant check

Changed paths:
U   php/php-src/trunk/Zend/zend_vm_def.h
U   php/php-src/trunk/Zend/zend_vm_execute.h

Modified: php/php-src/trunk/Zend/zend_vm_def.h
===
--- php/php-src/trunk/Zend/zend_vm_def.h2010-10-22 09:53:29 UTC (rev 
304608)
+++ php/php-src/trunk/Zend/zend_vm_def.h2010-10-22 09:56:39 UTC (rev 
304609)
@@ -4831,9 +4831,7 @@
if (EG(active_op_array)->try_catch_array[i].try_op > op_num) {
/* further blocks will not be relevant... */
break;
-   }
-   if (op_num >= EG(active_op_array)->try_catch_array[i].try_op
-   && op_num < 
EG(active_op_array)->try_catch_array[i].catch_op) {
+   } else if (op_num < 
EG(active_op_array)->try_catch_array[i].catch_op) {
catch_op_num = 
EX(op_array)->try_catch_array[i].catch_op;
catched = 1;
}

Modified: php/php-src/trunk/Zend/zend_vm_execute.h
===
--- php/php-src/trunk/Zend/zend_vm_execute.h2010-10-22 09:53:29 UTC (rev 
304608)
+++ php/php-src/trunk/Zend/zend_vm_execute.h2010-10-22 09:56:39 UTC (rev 
304609)
@@ -1043,9 +1043,7 @@
if (EG(active_op_array)->try_catch_array[i].try_op > op_num) {
/* further blocks will not be relevant... */
break;
-   }
-   if (op_num >= EG(active_op_array)->try_catch_array[i].try_op
-   && op_num < 
EG(active_op_array)->try_catch_array[i].catch_op) {
+   } else if (op_num < 
EG(active_op_array)->try_catch_array[i].catch_op) {
catch_op_num = 
EX(op_array)->try_catch_array[i].catch_op;
catched = 1;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php