andrey          Mon Jun 23 22:21:18 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/mysqlnd        mysqlnd_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.7&r2=1.2.2.8&diff_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.7        Wed May  7 15:14:26 2008
+++ php-src/ext/mysqlnd/mysqlnd_palloc.c        Mon 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

Reply via email to