logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

cvs: pecl /apc apc_compile.c apc_sma.c: msg#00119

Subject: cvs: pecl /apc apc_compile.c apc_sma.c
gopalv          Wed May 17 16:31:14 2006 UTC

  Modified files:              
    /pecl/apc   apc_compile.c apc_sma.c 
  Log:
  Debugging code to easily detect shm memory leaks. Fix a minor memory 
  leak for zend_class_entry * copies.
  
  
http://cvs.php.net/viewcvs.cgi/pecl/apc/apc_compile.c?r1=3.45&r2=3.46&diff_format=u
Index: pecl/apc/apc_compile.c
diff -u pecl/apc/apc_compile.c:3.45 pecl/apc/apc_compile.c:3.46
--- pecl/apc/apc_compile.c:3.45 Mon May 15 22:38:56 2006
+++ pecl/apc/apc_compile.c      Wed May 17 16:31:14 2006
@@ -28,7 +28,7 @@
 
  */
 
-/* $Id: apc_compile.c,v 3.45 2006/05/15 22:38:56 gopalv Exp $ */
+/* $Id: apc_compile.c,v 3.46 2006/05/17 16:31:14 gopalv Exp $ */
 
 #include "apc_compile.h"
 #include "apc_globals.h"
@@ -646,9 +646,6 @@
 
     dst->name = NULL;
     dst->builtin_functions = NULL;
-#ifdef ZEND_ENGINE_2
-    dst->filename = NULL;
-#endif
     memset(&dst->function_table, 0, sizeof(dst->function_table));
     memset(&dst->default_properties, 0, sizeof(dst->default_properties));
 #ifndef ZEND_ENGINE_2
@@ -656,6 +653,7 @@
 #else
     dst->static_members = NULL;
     dst->doc_comment = NULL;
+    dst->filename = NULL;
     memset(&dst->properties_info, 0, sizeof(dst->properties_info));
     memset(&dst->constants_table, 0, sizeof(dst->constants_table));
     memset(&dst->default_static_members, 0, 
sizeof(dst->default_static_members));
@@ -1578,6 +1576,7 @@
     deallocate(src->refcount);
 #else
     if(src->doc_comment) deallocate(src->doc_comment);
+    if(src->filename) deallocate(src->filename);
 #endif
 
     my_destroy_hashtable(&src->function_table,
http://cvs.php.net/viewcvs.cgi/pecl/apc/apc_sma.c?r1=1.51&r2=1.52&diff_format=u
Index: pecl/apc/apc_sma.c
diff -u pecl/apc/apc_sma.c:1.51 pecl/apc/apc_sma.c:1.52
--- pecl/apc/apc_sma.c:1.51     Sun May  7 00:54:28 2006
+++ pecl/apc/apc_sma.c  Wed May 17 16:31:14 2006
@@ -26,7 +26,7 @@
 
  */
 
-/* $Id: apc_sma.c,v 1.51 2006/05/07 00:54:28 gschlossnagle Exp $ */
+/* $Id: apc_sma.c,v 1.52 2006/05/17 16:31:14 gopalv Exp $ */
 
 #include "apc_sma.h"
 #include "apc.h"
@@ -65,10 +65,26 @@
 #endif
 };
 
+
+/* do not enable for threaded http servers */
+/* #define __APC_SMA_DEBUG__ 1 */
+
+#ifdef __APC_SMA_DEBUG__
+/* global counter for identifying blocks 
+ * Technically it is possible to do the same
+ * using offsets, but double allocations of the
+ * same offset can happen. */
+static volatile size_t block_id = 0;
+#endif
+
 typedef struct block_t block_t;
 struct block_t {
     size_t size;       /* size of this block */
     size_t next;       /* offset in segment of next free block */
+#ifdef __APC_SMA_DEBUG__
+    size_t canary;     /* canary to check for memory overwrites */
+    size_t id;         /* identifier for the memory block */ 
+#endif
 };
 
 /* The macros BLOCKAT and OFFSET are used for convenience throughout this
@@ -175,6 +191,12 @@
     }
     header->nfoffset = last_offset;
 
+#ifdef __APC_SMA_DEBUG__
+    cur->id = ++block_id;
+    cur->canary = 0x42424242;
+    fprintf(stderr, "allocate(realsize=%d,size=%d,id=%d)\n", (int)(size), 
(int)(cur->size), cur->id);
+#endif
+
     return OFFSET(cur) + alignword(sizeof(struct block_t));
 }
 /* }}} */
@@ -201,6 +223,11 @@
     cur = BLOCKAT(offset);
     cur->next = prv->next;
     prv->next = offset;
+
+#ifdef __APC_SMA_DEBUG__
+    fprintf(stderr, "free(size=%d,id=%d)\n", (int)(cur->size), cur->id);
+    assert(cur->canary == 0x42424242);
+#endif
     
     /* update the block header */
     header = (header_t*) shmaddr;



<Prev in Thread] Current Thread [Next in Thread>