Any comments ? I'm slightly hesistent to check-in without receiving any feedback (although I don't suspect the changes - because it's been working for sometime now)
-Madhu >-----Original Message----- >From: Mathihalli, Madhusudan >Sent: Wednesday, April 07, 2004 1:52 PM >To: [email protected] >Subject: [PATCH] Fix Alignment issues in apr_rmm.c > > >Hello, > While debugging some problem in mod_ldap, I ran into a >SIGBUS that was caused because of the presence of a 'double' >variable in the LDAP structures. I traced it down to a >alignment problem in apr_rmm.c. > > The following patch fixes the problem. Any comments ? > >-Madhu > >RCS file: /home/cvs/apr-util/misc/apr_rmm.c,v >retrieving revision 1.24 >diff -u -r1.24 apr_rmm.c >--- apr_rmm.c 20 Mar 2004 21:30:19 -0000 1.24 >+++ apr_rmm.c 7 Apr 2004 20:48:16 -0000 >@@ -40,6 +40,8 @@ > apr_anylock_t lock; > }; > >+#define SIZEOF(a) APR_ALIGN_DEFAULT(sizeof(a)) >+ > static apr_rmm_off_t find_block_by_offset(apr_rmm_t *rmm, >apr_rmm_off_t next, > apr_rmm_off_t find, >int includes) > { >@@ -87,7 +89,7 @@ > next = blk->next; > } > >- if (bestsize > sizeof(rmm_block_t) + size) { >+ if (bestsize > SIZEOF(rmm_block_t) + size) { > struct rmm_block_t *blk = >(rmm_block_t*)((char*)rmm->base + best); > struct rmm_block_t *new = >(rmm_block_t*)((char*)rmm->base + best + size >); > >@@ -197,7 +199,7 @@ > if ((rv = APR_ANYLOCK_LOCK(lock)) != APR_SUCCESS) > return rv; > >- (*rmm) = (apr_rmm_t *)apr_pcalloc(p, sizeof(apr_rmm_t)); >+ (*rmm) = (apr_rmm_t *)apr_pcalloc(p, SIZEOF(apr_rmm_t)); > (*rmm)->p = p; > (*rmm)->base = base; > (*rmm)->size = size; >@@ -205,7 +207,7 @@ > > (*rmm)->base->abssize = size; > (*rmm)->base->firstused = 0; >- (*rmm)->base->firstfree = sizeof(rmm_hdr_block_t); >+ (*rmm)->base->firstfree = SIZEOF(rmm_hdr_block_t); > > blk = (rmm_block_t *)((char*)base + (*rmm)->base->firstfree); > >@@ -263,7 +265,7 @@ > } > > /* sanity would be good here */ >- (*rmm) = (apr_rmm_t *)apr_pcalloc(p, sizeof(apr_rmm_t)); >+ (*rmm) = (apr_rmm_t *)apr_pcalloc(p, SIZEOF(apr_rmm_t)); > (*rmm)->p = p; > (*rmm)->base = base; > (*rmm)->size = (*rmm)->base->abssize; >@@ -285,11 +287,11 @@ > > APR_ANYLOCK_LOCK(&rmm->lock); > >- this = find_block_of_size(rmm, reqsize + sizeof(rmm_block_t)); >+ this = find_block_of_size(rmm, reqsize + SIZEOF(rmm_block_t)); > > if (this) { > move_block(rmm, this, 0); >- this += sizeof(rmm_block_t); >+ this += SIZEOF(rmm_block_t); > } > > APR_ANYLOCK_UNLOCK(&rmm->lock); >@@ -304,11 +306,11 @@ > > APR_ANYLOCK_LOCK(&rmm->lock); > >- this = find_block_of_size(rmm, reqsize + sizeof(rmm_block_t)); >+ this = find_block_of_size(rmm, reqsize + SIZEOF(rmm_block_t)); > > if (this) { > move_block(rmm, this, 0); >- this += sizeof(rmm_block_t); >+ this += SIZEOF(rmm_block_t); > memset((char*)rmm->base + this, 0, reqsize); > } > >@@ -353,11 +355,11 @@ > /* A little sanity check is always healthy, especially here. > * If we really cared, we could make this compile-time > */ >- if (this < sizeof(rmm_hdr_block_t) + sizeof(rmm_block_t)) { >+ if (this < SIZEOF(rmm_hdr_block_t) + SIZEOF(rmm_block_t)) { > return APR_EINVAL; > } > >- this -= sizeof(rmm_block_t); >+ this -= SIZEOF(rmm_block_t); > > blk = (rmm_block_t*)((char*)rmm->base + this); > >@@ -413,5 +415,5 @@ > > APU_DECLARE(apr_size_t) apr_rmm_overhead_get(int n) > { >- return sizeof(rmm_hdr_block_t) + n * sizeof(rmm_block_t); >+ return SIZEOF(rmm_hdr_block_t) + n * SIZEOF(rmm_block_t); > } >
