You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rainer Jung <ra...@kippdata.de> on 2011/01/17 18:51:46 UTC

Slotmem patch for alignment

Hi,

I wrote a small patch fixing an alignment issue for mod_slotmem:

http://people.apache.org/~rjung/patches/mod_slotmem_shm_alignment.patch

The problem is: mod_slotmem uses a header for meta data before the 
actual data slots. The addresses used for the data slots are offset by 
the size of the meta data. Currently this size is divisible by 4 but not 
by 8 and thus the data put into the slots is only aligned at 4 byte 
boudaries. If there is data inside the slots needing 8 byte alignment, 
then the compiler can not arrange for that.

I fixed it by increasing the offset to the APR default alignment. Please 
check whether you think there's a problem with it. It tried it in 
combination with a separate proxy patch I'll post in a minute and both 
together fix the crashes observed on Solaris Sparc.

One additional remark: I didn't actually understand the original code lines:

    apr_size_t basesize = (item_size * item_num);
    apr_size_t size = sizeof(sharedslotdesc_t) +
                      (item_num * sizeof(char)) + basesize;

What's the reason for the "(item_num * sizeof(char))" part? I can't 
actually see, where this part of the memory is being used.

Regards,

Rainer


Re: Slotmem patch for alignment

Posted by Jim Jagielski <ji...@jaguNET.com>.
On Jan 17, 2011, at 12:51 PM, Rainer Jung wrote:

> Hi,
> 
> I wrote a small patch fixing an alignment issue for mod_slotmem:
> 
> http://people.apache.org/~rjung/patches/mod_slotmem_shm_alignment.patch
> 
> The problem is: mod_slotmem uses a header for meta data before the actual data slots. The addresses used for the data slots are offset by the size of the meta data. Currently this size is divisible by 4 but not by 8 and thus the data put into the slots is only aligned at 4 byte boudaries. If there is data inside the slots needing 8 byte alignment, then the compiler can not arrange for that.
> 
> I fixed it by increasing the offset to the APR default alignment. Please check whether you think there's a problem with it. It tried it in combination with a separate proxy patch I'll post in a minute and both together fix the crashes observed on Solaris Sparc.
> 

Sounds good.

> One additional remark: I didn't actually understand the original code lines:
> 
>   apr_size_t basesize = (item_size * item_num);
>   apr_size_t size = sizeof(sharedslotdesc_t) +
>                     (item_num * sizeof(char)) + basesize;
> 
> What's the reason for the "(item_num * sizeof(char))" part? I can't actually see, where this part of the memory is being used.
> 

It's the inuse table

> Regards,
> 
> Rainer
>