Blair Zajac wrote:
> 
> I'm using the bounds checking gcc 3.1.1 to check for memory issues
> in Apache and Subversion.  This patch to gcc compiles the code with
> extra checks for illegal memory accesses, invalid pointers, etc and
> runs a lot faster than valgrind.  See
> 
>     http://web.inter.nl.net/hcc/Haj.Ten.Brugge/
> 
> There's a core dump from the bounds checking compiler when running
> httpd -l with today's HEAD
> 

Here's an updated patch with an additional change that was caught with
Subversion's make check, replacing

-    if (!ps->got_a_new_node && node->first_avail + size < node->endp) {

with

+    if (!ps->got_a_new_node && node->endp - node->first_avail > size) {

Best,
Blair

-- 
Blair Zajac <[EMAIL PROTECTED]>
Web and OS performance plots - http://www.orcaware.com/orca/
Index: memory/unix/apr_pools.c
===================================================================
RCS file: /home/cvspublic/apr/memory/unix/apr_pools.c,v
retrieving revision 1.183
diff -u -r1.183 apr_pools.c
--- memory/unix/apr_pools.c     13 Jul 2002 21:38:02 -0000      1.183
+++ memory/unix/apr_pools.c     31 Jul 2002 23:07:09 -0000
@@ -606,24 +606,21 @@
 {
     apr_memnode_t *active, *node;
     void *mem;
-    char *endp;
     apr_uint32_t free_index;
 
     size = APR_ALIGN_DEFAULT(size);
     active = pool->active;
 
     /* If the active node has enough bytes left, use it. */
-    endp = active->first_avail + size;
-    if (endp < active->endp) {
+    if (size < active->endp - active->first_avail) {
         mem = active->first_avail;
-        active->first_avail = endp;
+        active->first_avail = active->first_avail + size;
 
         return mem;
     }
 
     node = active->next;
-    endp = node->first_avail + size;
-    if (endp < node->endp) {
+    if (size < node->endp - node->first_avail) {
         *node->ref = node->next;
         node->next->ref = node->ref;
     }
@@ -634,13 +631,12 @@
 
             return NULL;
         }
-        endp = node->first_avail + size;
     }
 
     node->free_index = 0;
 
     mem = node->first_avail;
-    node->first_avail = endp;
+    node->first_avail = node->first_avail + size;
 
     node->ref = active->ref;
     *node->ref = node;
@@ -929,7 +925,7 @@
         size = APR_PSPRINTF_MIN_STRINGSIZE;
 
     node = active->next;
-    if (!ps->got_a_new_node && node->first_avail + size < node->endp) {
+    if (!ps->got_a_new_node && node->endp - node->first_avail > size) {
         *node->ref = node->next;
         node->next->ref = node->ref;
 

Reply via email to