On Tue, 13 Jul 2004 15:34:28 +0400
Antony Dovgal <[EMAIL PROTECTED]> wrote:

> Hi all!
> 
> That's what valgrind says:
> 
> 1) 
> Zend/tests/bug26166.phpt
> 
> Zend/zend_execute.c:1352      
> EX(Ts) = (temp_variable *) safe_emalloc(sizeof(temp_variable),
> op_array->T, 0);
> 
> ==8511== 40 bytes in 1 blocks are still reachable in loss record 2 of
> 7==8511==    at 0x3C01E375: malloc (vg_replace_malloc.c:105)
> ==8511==    by 0x8222A55: _emalloc (zend_alloc.c:182)
> ==8511==    by 0x8222C77: _safe_emalloc (zend_alloc.c:238)
> ==8511==    by 0x8266E78: execute (zend_execute.c:1352)
> 
> 2)
> Zend/tests/bug20240.phpt
> 
> ==8478== 40 bytes in 1 blocks are still reachable in loss record 2 of
> 7==8478==    at 0x3C01E375: malloc (vg_replace_malloc.c:105)
> ==8478==    by 0x8222A55: _emalloc (zend_alloc.c:182)
> ==8478==    by 0x8231488: call_user_function (zend_execute_API.c:517)
> ==8478==    by 0x816D03B: user_shutdown_function_call
> (basic_functions.c:2088)

Dunno if it's the right thing to add if()'s around emalloc(), but with
attached patch these warnings disappear, reducing valgrind logs in a
half.

---
WBR,
Antony Dovgal aka tony2001
[EMAIL PROTECTED] || [EMAIL PROTECTED]
Index: zend_execute_API.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute_API.c,v
retrieving revision 1.287
diff -u -r1.287 zend_execute_API.c
--- zend_execute_API.c  18 May 2004 20:14:54 -0000      1.287
+++ zend_execute_API.c  13 Jul 2004 17:04:14 -0000
@@ -514,11 +514,15 @@
 
 int call_user_function(HashTable *function_table, zval **object_pp, zval 
*function_name, zval *retval_ptr, zend_uint param_count, zval *params[] TSRMLS_DC)
 {
-       zval ***params_array = (zval ***) emalloc(sizeof(zval **)*param_count);
+       zval ***params_array = NULL;
        zend_uint i;
        int ex_retval;
        zval *local_retval_ptr;
 
+       if (param_count) {
+               params_array = (zval ***) emalloc(sizeof(zval **)*param_count);        
 
+       }
+       
        for (i=0; i<param_count; i++) {
                params_array[i] = &params[i];
        }
@@ -528,7 +532,10 @@
        } else {
                INIT_ZVAL(*retval_ptr);
        }
-       efree(params_array);
+
+       if (param_count) {
+               efree(params_array);
+       }
        return ex_retval;
 }
 
Index: zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.652
diff -u -r1.652 zend_execute.c
--- zend_execute.c      12 Jul 2004 17:47:29 -0000      1.652
+++ zend_execute.c      13 Jul 2004 17:04:15 -0000
@@ -1330,7 +1330,9 @@
        }
 
 #define RETURN_FROM_EXECUTE_LOOP(execute_data)                                        
                 \
-       efree(EX(Ts));                                                                 
                                 \
+       if (EX(Ts)) {                                                                  
                                                 \
+               efree(EX(Ts));                                                         
                                                 \
+       }                                                                              
                                                                 \
        EG(in_execution) = EX(original_in_execution);                                  
                 \
        EG(current_execute_data) = EX(prev_execute_data);                              
                 \
        return 1; /* CHECK_ME */
@@ -1349,7 +1351,10 @@
        /* Initialize execute_data */
        EX(fbc) = NULL;
        EX(object) = NULL;
-       EX(Ts) = (temp_variable *) safe_emalloc(sizeof(temp_variable), op_array->T, 0);
+       EX(Ts) = NULL;
+       if (op_array->T) {
+               EX(Ts) = (temp_variable *) safe_emalloc(sizeof(temp_variable), 
op_array->T, 0);
+       }
        EX(op_array) = op_array;
        EX(original_in_execution) = EG(in_execution);
        EX(prev_execute_data) = EG(current_execute_data);

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to