[PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c

2009-06-16 Thread Andrey Hristov
andrey  Tue Jun 16 07:53:35 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/mysqlndmysqlnd_palloc.c 
  Log:
  MFH:
  Use Zend's allocator instead of libc's and also don't try to work on
  zvals that are NULLs.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_palloc.c?r1=1.2.2.18r2=1.2.2.19diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_palloc.c
diff -u php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.18 
php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.19
--- php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.18   Thu Jun 11 08:30:08 2009
+++ php-src/ext/mysqlnd/mysqlnd_palloc.cTue Jun 16 07:53:35 2009
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: mysqlnd_palloc.c,v 1.2.2.18 2009/06/11 08:30:08 andrey Exp $ */
+/* $Id: mysqlnd_palloc.c,v 1.2.2.19 2009/06/16 07:53:35 andrey Exp $ */
 #include php.h
 #include mysqlnd.h
 #include mysqlnd_priv.h
@@ -139,7 +139,7 @@
 /* {{{ _mysqlnd_palloc_init_thd_cache */
 MYSQLND_THD_ZVAL_PCACHE* mysqlnd_palloc_init_thd_cache(MYSQLND_ZVAL_PCACHE * 
const cache TSRMLS_DC)
 {
-   MYSQLND_THD_ZVAL_PCACHE *ret = calloc(1, 
sizeof(MYSQLND_THD_ZVAL_PCACHE));
+   MYSQLND_THD_ZVAL_PCACHE *ret = mnd_ecalloc(1, 
sizeof(MYSQLND_THD_ZVAL_PCACHE));
DBG_ENTER(_mysqlnd_palloc_init_thd_cache);
DBG_INF_FMT(ret = %p, ret);

@@ -161,7 +161,7 @@
ret-references = 1;
 
/* 1. Initialize the GC list */
-   ret-gc_list.ptr_line = calloc(cache-max_items, sizeof(mysqlnd_zval 
*));
+   ret-gc_list.ptr_line = mnd_ecalloc(cache-max_items, 
sizeof(mysqlnd_zval *));
/* Backward and forward looping is possible */
ret-gc_list.last_added = ret-gc_list.ptr_line;
ret-gc_list.canary1 = (void*)0xCAFE;
@@ -233,8 +233,8 @@
UNLOCK_PCACHE(global_cache);
 
}
-   mnd_free(thd_cache-gc_list.ptr_line);
-   mnd_free(thd_cache);
+   mnd_efree(thd_cache-gc_list.ptr_line);
+   mnd_efree(thd_cache);
 
DBG_VOID_RETURN;
 }
@@ -413,6 +413,9 @@
 {
MYSQLND_ZVAL_PCACHE *cache;
DBG_ENTER(mysqlnd_palloc_zval_ptr_dtor);
+   if (!*zv) {
+   DBG_VOID_RETURN;
+   }
if (thd_cache) {
DBG_INF_FMT(cache=%p parent_block=%p last_in_block=%p *zv=%p 
refc=%d type=%d ,
thd_cache,



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



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c

2009-06-11 Thread Pierre Joye
hi,

This change sounds wrong. The obj pointer is being used without being
initialized:

ext\mysqlnd\mysqlnd_wireprotocol.c(1632) : warning C4700:
uninitialized local variable 'obj' used

Cheers,

On Mon, Jun 8, 2009 at 7:31 PM, Lukas Kahwe Smithm...@pooteeweet.org wrote:

 On 08.06.2009, at 12:20, Andrey Hristov wrote:

 andrey          Mon Jun  8 10:20:27 2009 UTC

  Modified files:              (Branch: PHP_5_3)
   /php-src/ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c
  Log:
  Merge with HEAD. Someone committed changes to HEAD and did not merge back
 to
  the branch.
  Also switch off the zval cache, for now.


 puh .. you are aware that we want to do a commit freeze tonight? and release
 RC3, which should hopefully become the stable release for 5.3?
 since 2-3 weeks there is a constant stream of patches that seem to do pretty
 fundamental changes and design choices.

 regards,
 Lukas Kahwe Smith
 m...@pooteeweet.org




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





-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org

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



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c

2009-06-11 Thread Andrey Hristov

 Hi Pierre,
Pierre Joye wrote:

hi,

This change sounds wrong. The obj pointer is being used without being
initialized:

ext\mysqlnd\mysqlnd_wireprotocol.c(1632) : warning C4700:
uninitialized local variable 'obj' used

Cheers,


Check with your eyes, the compiler is wrong.
obj is touched only if allocated is FALSE but it is never FALSE if the 
zval cache has been switched off.



Andrey


On Mon, Jun 8, 2009 at 7:31 PM, Lukas Kahwe Smithm...@pooteeweet.org wrote:

On 08.06.2009, at 12:20, Andrey Hristov wrote:


andrey  Mon Jun  8 10:20:27 2009 UTC

 Modified files:  (Branch: PHP_5_3)
  /php-src/ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c
 Log:
 Merge with HEAD. Someone committed changes to HEAD and did not merge back
to
 the branch.
 Also switch off the zval cache, for now.


puh .. you are aware that we want to do a commit freeze tonight? and release
RC3, which should hopefully become the stable release for 5.3?
since 2-3 weeks there is a constant stream of patches that seem to do pretty
fundamental changes and design choices.

regards,
Lukas Kahwe Smith
m...@pooteeweet.org




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









--
Andrey Hristov, Connectors Software Developer, Database Group
Sun Microsystems GmbH, Sonnenallee 1, 85551 Kirchheim-Heimstetten
Amtsgericht Muenchen: HRB161028
Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Haering

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



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c

2009-06-11 Thread Andrey Hristov

 Hi Lukas,
On Mon, Jun 8, 2009 at 7:31 PM, Lukas Kahwe Smithm...@pooteeweet.org wrote:

On 08.06.2009, at 12:20, Andrey Hristov wrote:


andrey  Mon Jun  8 10:20:27 2009 UTC

 Modified files:  (Branch: PHP_5_3)
  /php-src/ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c
 Log:
 Merge with HEAD. Someone committed changes to HEAD and did not merge back
to
 the branch.
 Also switch off the zval cache, for now.


puh .. you are aware that we want to do a commit freeze tonight? and release
RC3, which should hopefully become the stable release for 5.3?
since 2-3 weeks there is a constant stream of patches that seem to do pretty
fundamental changes and design choices.

regards,
Lukas Kahwe Smith
m...@pooteeweet.org




The zval cache is a feature which has been switched off. Why do you 
think I switch off a feature? Because there was a bug report which was 
few months old affecting all 5_3 versions including RC1 and RC2. The 
problem was manifesting itself on Windows only under load. I switched 
the feature and the problem is gone, according to the user.


Andrey


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



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c

2009-06-11 Thread Pierre Joye
hi Andrey,

On Thu, Jun 11, 2009 at 7:25 PM, Andrey Hristovandrey.hris...@sun.com wrote:
  Hi Pierre,
 Pierre Joye wrote:

 hi,

 This change sounds wrong. The obj pointer is being used without being
 initialized:

 ext\mysqlnd\mysqlnd_wireprotocol.c(1632) : warning C4700:
 uninitialized local variable 'obj' used

 Cheers,

 Check with your eyes, the compiler is wrong.
 obj is touched only if allocated is FALSE but it is never FALSE if the zval
 cache has been switched off.

Please read http://www.thefreedictionary.com/seems

Now that the meaning of this word has been cleared :), can you add a
ifdef around that code then?

thanks for the quick reply,

Cheers,
-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org

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



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c

2009-06-11 Thread Pierre Joye
On Thu, Jun 11, 2009 at 7:42 PM, Andrey Hristovp...@hristov.com wrote:

 no :)

Why not? it is clearly pointless when ZVAL_CACHE is not set.

 But you can send the case to your colleagues at the compiler team so
 they can analyze why the compiler failed to recognize it :)

already sent :)

  I like the MS
 compiler, it gives more warnings than gcc,

Yeah, me too :) I would like to run some more analyzes tools as well,
one of these days :)

 but in this case was wrong :( I
 am curious why it does complain about one line although there are few places
 where obj is used and guarded by that allocated variable.


Cheers,
-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org

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



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c

2009-06-11 Thread Andrey Hristov

 Hi Pierre,
Pierre Joye wrote:

hi Andrey,

On Thu, Jun 11, 2009 at 7:25 PM, Andrey Hristovandrey.hris...@sun.com wrote:

 Hi Pierre,
Pierre Joye wrote:

hi,

This change sounds wrong. The obj pointer is being used without being
initialized:

ext\mysqlnd\mysqlnd_wireprotocol.c(1632) : warning C4700:
uninitialized local variable 'obj' used

Cheers,

Check with your eyes, the compiler is wrong.
obj is touched only if allocated is FALSE but it is never FALSE if the zval
cache has been switched off.


Please read http://www.thefreedictionary.com/seems

Now that the meaning of this word has been cleared :), can you add a
ifdef around that code then?

thanks for the quick reply,


no :) But you can send the case to your colleagues at the compiler team 
so they can analyze why the compiler failed to recognize it :) I like 
the MS compiler, it gives more warnings than gcc, but in this case was 
wrong :( I am curious why it does complain about one line although there 
are few places where obj is used and guarded by that allocated variable.


Best,
Andrey


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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c

2009-06-08 Thread Andrey Hristov
andrey  Mon Jun  8 10:20:27 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/mysqlndmysqlnd_palloc.c mysqlnd_wireprotocol.c 
  Log:
  Merge with HEAD. Someone committed changes to HEAD and did not merge back to
  the branch.
  Also switch off the zval cache, for now.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_palloc.c?r1=1.2.2.16r2=1.2.2.17diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_palloc.c
diff -u php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.16 
php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.17
--- php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.16   Thu May 28 16:35:41 2009
+++ php-src/ext/mysqlnd/mysqlnd_palloc.cMon Jun  8 10:20:27 2009
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: mysqlnd_palloc.c,v 1.2.2.16 2009/05/28 16:35:41 andrey Exp $ */
+/* $Id: mysqlnd_palloc.c,v 1.2.2.17 2009/06/08 10:20:27 andrey Exp $ */
 #include php.h
 #include mysqlnd.h
 #include mysqlnd_priv.h
@@ -549,48 +549,45 @@
 {
if (cache) {
 #if PHP_MAJOR_VERSION = 6
+   UChar *ustr;
+   int ulen;
+   
TSRMLS_FETCH();
 #endif
 
LOCK_PCACHE(cache);
array_init(return_value);
 #if PHP_MAJOR_VERSION = 6
-   if (UG(unicode)) {
-   UChar *ustr;
-   int ulen;
-
-   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
put_hits, sizeof(put_hits) TSRMLS_CC);
-   add_u_assoc_long_ex(return_value, IS_UNICODE, 
ZSTR(ustr), ulen + 1, cache-put_hits);
-   efree(ustr);
-   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
put_misses, sizeof(put_misses) TSRMLS_CC);
-   add_u_assoc_long_ex(return_value, IS_UNICODE, 
ZSTR(ustr), ulen + 1, cache-put_hits);
-   efree(ustr);
-   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
get_hits, sizeof(get_hits) TSRMLS_CC);
-   add_u_assoc_long_ex(return_value, IS_UNICODE, 
ZSTR(ustr), ulen + 1, cache-put_hits);
-   efree(ustr);
-   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
get_misses, sizeof(get_misses) TSRMLS_CC);
-   add_u_assoc_long_ex(return_value, IS_UNICODE, 
ZSTR(ustr), ulen + 1, cache-put_hits);
-   efree(ustr);
-   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
size, sizeof(size) TSRMLS_CC);
-   add_u_assoc_long_ex(return_value, IS_UNICODE, 
ZSTR(ustr), ulen + 1, cache-put_hits);
-   efree(ustr);
-   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
free_items, sizeof(free_items) TSRMLS_CC);
-   add_u_assoc_long_ex(return_value, IS_UNICODE, 
ZSTR(ustr), ulen + 1, cache-put_hits);
-   efree(ustr);
-   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
references, sizeof(references) TSRMLS_CC);
-   add_u_assoc_long_ex(return_value, IS_UNICODE, 
ZSTR(ustr), ulen + 1, cache-put_hits);
-   efree(ustr);
-   } else
+   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, put_hits, 
sizeof(put_hits) TSRMLS_CC);
+   add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen 
+ 1, cache-put_hits);
+   efree(ustr);
+   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
put_misses, sizeof(put_misses) TSRMLS_CC);
+   add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen 
+ 1, cache-put_hits);
+   efree(ustr);
+   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, get_hits, 
sizeof(get_hits) TSRMLS_CC);
+   add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen 
+ 1, cache-put_hits);
+   efree(ustr);
+   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
get_misses, sizeof(get_misses) TSRMLS_CC);
+   add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen 
+ 1, cache-put_hits);
+   efree(ustr);
+   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, size, 
sizeof(size) TSRMLS_CC);
+   add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen 
+ 1, cache-put_hits);
+   efree(ustr);
+   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
free_items, sizeof(free_items) TSRMLS_CC);
+   add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen 
+ 1, cache-put_hits);
+   efree(ustr);
+   zend_string_to_unicode(UG(utf8_conv), ustr, ulen, 
references, sizeof(references) TSRMLS_CC);
+   add_u_assoc_long_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen 
+ 1, cache-put_hits);
+   efree(ustr);
+#else
+   

Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c

2009-06-08 Thread Lukas Kahwe Smith


On 08.06.2009, at 12:20, Andrey Hristov wrote:


andrey  Mon Jun  8 10:20:27 2009 UTC

 Modified files:  (Branch: PHP_5_3)
   /php-src/ext/mysqlnd mysqlnd_palloc.c mysqlnd_wireprotocol.c
 Log:
 Merge with HEAD. Someone committed changes to HEAD and did not  
merge back to

 the branch.
 Also switch off the zval cache, for now.



puh .. you are aware that we want to do a commit freeze tonight? and  
release RC3, which should hopefully become the stable release for 5.3?
since 2-3 weeks there is a constant stream of patches that seem to do  
pretty fundamental changes and design choices.


regards,
Lukas Kahwe Smith
m...@pooteeweet.org




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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c mysqlnd_ps.c mysqlnd_ps_codec.c mysqlnd_result.c

2009-05-28 Thread Andrey Hristov
andrey  Thu May 28 16:35:42 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/mysqlndmysqlnd_palloc.c mysqlnd_ps.c 
mysqlnd_ps_codec.c mysqlnd_result.c 
  Log:
  MFH:Fix a problem with cursors, which did not happen with unbuffered PS for
  some reason. Double free of the data, which led to valgrind warnigns.
  The fix actually optimizes the code in this cases because the old code
  used copy_ctor while the new one skips it because it is not needed.
  Transferring data ownership and nulling works best, for PS where we
  always copy the string from the result set, unlike the text protocol.
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_palloc.c?r1=1.2.2.15r2=1.2.2.16diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_palloc.c
diff -u php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.15 
php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.16
--- php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.15   Mon Mar 30 16:52:33 2009
+++ php-src/ext/mysqlnd/mysqlnd_palloc.cThu May 28 16:35:41 2009
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: mysqlnd_palloc.c,v 1.2.2.15 2009/03/30 16:52:33 felipe Exp $ */
+/* $Id: mysqlnd_palloc.c,v 1.2.2.16 2009/05/28 16:35:41 andrey Exp $ */
 #include php.h
 #include mysqlnd.h
 #include mysqlnd_priv.h
@@ -497,9 +497,14 @@
*(thd_cache-gc_list.last_added++) = (mysqlnd_zval *)*zv;
UNLOCK_PCACHE(cache);
} else {
+   DBG_INF(No user reference);
/* No user reference */
if (((mysqlnd_zval *)*zv)-point_type == 
MYSQLND_POINTS_EXT_BUFFER) {
-   /* PS are here and also in Unicode mode, for non-binary 
 */
+   DBG_INF(Points to external buffer. Calling zval_dtor);
+   /*
+ PS are here
+ Unicode mode goes also here if the column is not 
binary but a text
+   */
zval_dtor(*zv);
}
LOCK_PCACHE(cache);
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_ps.c?r1=1.3.2.24r2=1.3.2.25diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_ps.c
diff -u php-src/ext/mysqlnd/mysqlnd_ps.c:1.3.2.24 
php-src/ext/mysqlnd/mysqlnd_ps.c:1.3.2.25
--- php-src/ext/mysqlnd/mysqlnd_ps.c:1.3.2.24   Mon Feb 16 17:26:43 2009
+++ php-src/ext/mysqlnd/mysqlnd_ps.cThu May 28 16:35:41 2009
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: mysqlnd_ps.c,v 1.3.2.24 2009/02/16 17:26:43 johannes Exp $ */
+/* $Id: mysqlnd_ps.c,v 1.3.2.25 2009/05/28 16:35:41 andrey Exp $ */
 #include php.h
 #include mysqlnd.h
 #include mysqlnd_wireprotocol.h
@@ -536,12 +536,14 @@

stmt-upsert_status.server_status  SERVER_STATUS_CURSOR_EXISTS);
 
if (stmt-upsert_status.server_status  
SERVER_STATUS_CURSOR_EXISTS) {
+   DBG_INF(cursor exists);
stmt-cursor_exists = TRUE;
CONN_SET_STATE(conn, CONN_READY);
/* Only cursor read */
stmt-default_rset_handler = 
stmt-m-use_result;
DBG_INF(use_result);
} else if (stmt-flags  CURSOR_TYPE_READ_ONLY) {
+   DBG_INF(asked for cursor but got none);
/*
  We have asked for CURSOR but got no cursor, 
because the condition
  above is not fulfilled. Then...
@@ -556,6 +558,7 @@
stmt-default_rset_handler = 
stmt-m-store_result;
DBG_INF(store_result);
} else {
+   DBG_INF(no cursor);
/* preferred is unbuffered read */
stmt-default_rset_handler = 
stmt-m-use_result;
DBG_INF(use_result);
@@ -853,15 +856,10 @@
  stmt-result_bind[i].zv has been 
already destructed
  in mysqlnd_unbuffered_free_last_data()
*/
-
 #ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
zval_dtor(stmt-result_bind[i].zv);
 #endif
if (IS_NULL != 
(Z_TYPE_P(stmt-result_bind[i].zv) = Z_TYPE_P(data)) ) {
-   stmt-result_bind[i].zv-value 
= data-value;
-#ifndef WE_DONT_COPY_IN_BUFFERED_AND_UNBUFFERED_BECAUSEOF_IS_REF
-   
zval_copy_ctor(stmt-result_bind[i].zv);
-#endif 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c

2008-06-24 Thread Andrey Hristov
andrey  Tue Jun 24 06:56:36 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/mysqlndmysqlnd_palloc.c 
  Log:
  Even more debug info
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_palloc.c?r1=1.2.2.8r2=1.2.2.9diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_palloc.c
diff -u php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.8 
php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.9
--- php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.8Mon Jun 23 22:21:18 2008
+++ php-src/ext/mysqlnd/mysqlnd_palloc.cTue Jun 24 06:56:36 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: mysqlnd_palloc.c,v 1.2.2.8 2008/06/23 22:21:18 andrey Exp $ */
+/* $Id: mysqlnd_palloc.c,v 1.2.2.9 2008/06/24 06:56:36 andrey Exp $ */
 #include php.h
 #include mysqlnd.h
 #include mysqlnd_priv.h
@@ -67,6 +67,8 @@
/* One more for empty position of last_added - always 0x0, bounds 
checking */
ret-free_list.ptr_line = calloc(ret-max_items + 1, 
sizeof(mysqlnd_zval *));
ret-free_list.last_added = ret-free_list.ptr_line + ret-max_items;
+   ret-free_list.canary1 = (void*)0xBEEF;
+   ret-free_list.canary2 = (void*)0xAFFE;
 
/* 3. Allocate and initialize our zvals and initialize the free list */
ret-block = calloc(ret-max_items, sizeof(mysqlnd_zval));
@@ -154,7 +156,10 @@
ret-gc_list.ptr_line = calloc(cache-max_items, sizeof(mysqlnd_zval 
*));
/* Backward and forward looping is possible */
ret-gc_list.last_added = ret-gc_list.ptr_line;
+   ret-gc_list.canary1 = (void*)0xCAFE;
+   ret-gc_list.canary2 = (void*)0x190280;
 
+   DBG_INF_FMT(ptr_line=%p last_added=%p, ret-gc_list.ptr_line, 
ret-gc_list.last_added);
DBG_RETURN(ret);
 }
 /* }}} */
@@ -166,7 +171,8 @@
DBG_ENTER(_mysqlnd_palloc_get_thd_cache_reference);
if (cache) {
++cache-references;
-   DBG_INF_FMT(cache=%p new_refc=%d, *cache, cache-references);
+   DBG_INF_FMT(cache=%p new_refc=%d gc_list.canary1=%p 
gc_list.canary2=%p,
+   *cache, cache-references, 
cache-gc_list.canary1, cache-gc_list.canary2);
mysqlnd_palloc_get_cache_reference(cache-parent);
}
DBG_RETURN(cache);
@@ -202,7 +208,10 @@
DBG_ENTER(_mysqlnd_palloc_free_thd_cache_reference);
if (*cache) {
--(*cache)-parent-references;
-   DBG_INF_FMT(cache=%p references_left=%d, *cache, 
(*cache)-references);
+   DBG_INF_FMT(cache=%p references_left=%d canary1=%p canary2=%p,
+   *cache, (*cache)-references, 
(*cache)-gc_list.canary1, (*cache)-gc_list.canary2);
+
+   DBG_INF_FMT(gc_list.ptr_line=%p gc_list.last_added=%p, 
(*cache)-gc_list.ptr_line, (*cache)-gc_list.last_added);
 
if (--(*cache)-references == 0) {
mysqlnd_palloc_free_thd_cache(*cache TSRMLS_CC);
@@ -309,15 +318,19 @@
DBG_INF_FMT(cache=%p *last_added=%p free_items=%d,
thd_cache, 
thd_cache-parent-free_list.last_added,
thd_cache-parent-free_items);
+   DBG_INF_FMT(gc_list.ptr_line=%p gc_list.last_added=%p 
gc_list.canary1=%p gc_list.canary2=%p,
+   thd_cache-gc_list.ptr_line, 
thd_cache-gc_list.last_added,
+   thd_cache-gc_list.canary1, 
thd_cache-gc_list.canary2);
}
 
if (thd_cache) {
MYSQLND_ZVAL_PCACHE *cache = thd_cache-parent;
LOCK_PCACHE(cache);
 
-   DBG_INF_FMT(free_items=%d free_list.ptr_line=%p 
free_list.last_added=%p *free_list.last_added=%p,
+   DBG_INF_FMT(free_items=%d free_list.ptr_line=%p 
free_list.last_added=%p *free_list.last_added=%p free_list.canary1=%p 
free_list.canary2=%p,
cache-free_items, 
cache-free_list.ptr_line, cache-free_list.last_added,
-   *cache-free_list.last_added);
+   *cache-free_list.last_added,
+   cache-free_list.canary1, 
cache-free_list.canary2);
 
/* We have max_items + 1 allocated block for free_list, thus we 
know if we */
if ((ret = *cache-free_list.last_added)) {
@@ -367,6 +380,8 @@
thd_cache-parent-block,
thd_cache-parent-last_in_block,
*zv, Z_REFCOUNT_PP(zv), type);
+   DBG_INF_FMT(gc_list.ptr_line=%p gc_list.last_added=%p 
gc_list.canary1=%p gc_list.canary2=%p,
+   thd_cache-gc_list.ptr_line, 
thd_cache-gc_list.last_added, thd_cache-gc_list.canary1, 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/mysqlnd mysqlnd_palloc.c

2008-06-23 Thread Andrey Hristov
andrey  Mon Jun 23 22:21:18 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/mysqlndmysqlnd_palloc.c 
  Log:
  Added more debug info for tracking problems
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqlnd/mysqlnd_palloc.c?r1=1.2.2.7r2=1.2.2.8diff_format=u
Index: php-src/ext/mysqlnd/mysqlnd_palloc.c
diff -u php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.7 
php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.8
--- php-src/ext/mysqlnd/mysqlnd_palloc.c:1.2.2.7Wed May  7 15:14:26 2008
+++ php-src/ext/mysqlnd/mysqlnd_palloc.cMon Jun 23 22:21:18 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: mysqlnd_palloc.c,v 1.2.2.7 2008/05/07 15:14:26 andrey Exp $ */
+/* $Id: mysqlnd_palloc.c,v 1.2.2.8 2008/06/23 22:21:18 andrey Exp $ */
 #include php.h
 #include mysqlnd.h
 #include mysqlnd_priv.h
@@ -132,6 +132,16 @@
MYSQLND_THD_ZVAL_PCACHE *ret = calloc(1, 
sizeof(MYSQLND_THD_ZVAL_PCACHE));
DBG_ENTER(_mysqlnd_palloc_init_thd_cache);
DBG_INF_FMT(ret = %p, ret);
+   
+#if PHP_DEBUG
+   LOCK_PCACHE(cache);
+   if (cache-references == 1  cache-max_items != cache-free_items) {
+   UNLOCK_PCACHE(cache);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, No references to 
mysqlnd's zval cache but max_items != free_items);
+   } else {
+   UNLOCK_PCACHE(cache);
+   }
+#endif
ret-parent = mysqlnd_palloc_get_cache_reference(cache);
 
 #ifdef ZTS
@@ -304,7 +314,12 @@
if (thd_cache) {
MYSQLND_ZVAL_PCACHE *cache = thd_cache-parent;
LOCK_PCACHE(cache);
-   
+
+   DBG_INF_FMT(free_items=%d free_list.ptr_line=%p 
free_list.last_added=%p *free_list.last_added=%p,
+   cache-free_items, 
cache-free_list.ptr_line, cache-free_list.last_added,
+   *cache-free_list.last_added);
+
+   /* We have max_items + 1 allocated block for free_list, thus we 
know if we */
if ((ret = *cache-free_list.last_added)) {
*cache-free_list.last_added++ = NULL;
*allocated = FALSE;
@@ -427,6 +442,18 @@
  shutdown :(.
*/
LOCK_PCACHE(cache);
+   DBG_INF_FMT(gc_list.ptr_line=%p gc_list.last_added=%p 
*gc_list.last_added=%p,
+   thd_cache-gc_list.ptr_line,
+   thd_cache-gc_list.last_added,
+   *thd_cache-gc_list.last_added);
+   if ((thd_cache-gc_list.last_added - 
thd_cache-gc_list.ptr_line)  cache-max_items) {
+   DBG_ERR(Buffer overflow follows);
+   DBG_ERR_FMT(parent-max_items=%d parent-free_items=%d 
diff=%d,
+   cache-max_items, 
cache-free_items,
+   thd_cache-gc_list.last_added - 
thd_cache-gc_list.ptr_line);
+
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, We will 
get buffer overflow);
+   }
++cache-put_misses;
*(thd_cache-gc_list.last_added++) = (mysqlnd_zval *)*zv;
UNLOCK_PCACHE(cache);
@@ -487,6 +514,7 @@
}
 
p = thd_cache-gc_list.ptr_line;
+
LOCK_PCACHE(cache);
while (p  thd_cache-gc_list.last_added) {
(*p)-point_type = MYSQLND_POINTS_FREE;



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