Memory allocation still not properly aligned.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I can see that you did fix the alignment in "pj_pool_create_block", but 
as near as I can tell that function is only called by 
"pj_pool_allocate_find" when the current blocks can't satisfy a request 
and a new block needs to be created. The problem seems to be that (for a 
caching pool factory) the very first block is created with a different 
function, "pj_pool_create_int", and that function is not setting the 
alignment properly. And as long as we're on the subject, it looks like 
the "reset_pool" function also sets the alignment for the remaining 
block incorrectly as well, but I haven't noticed because I don't use it.

Also, I noticed that the code you used to align the memory in 
"pj_pool_create_block", namely:

     block->cur = (unsigned char*)
                 (((unsigned long)block->buf + PJ_POOL_ALIGNMENT - 1) &
                  ~(PJ_POOL_ALIGNMENT - 1));

doesn't work in 64-bit Windows because "long" is still only 32 bits 
wide. A way of doing this that doesn't have that problem is:

    block->cur = block_buf + (-(long)(block->buf) & (PJ_POOL_ALIGNMENT-1));

I hope this makes sense.

John Ridges


pjsip-request at lists.pjsip.org wrote:
> Date: Thu, 28 Jan 2010 14:11:57 +0000
> From: Benny Prijono <bennylp@xxxxxxxxx>
> To: pjsip list <pjsip at lists.pjsip.org>
> Subject: Re: Memory allocation still not properly aligned.
> Message-ID:
> 	<49a4be81001280611q56d9a236vf0104dbe7f4f74b6 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Wed, Jan 27, 2010 at 8:34 PM, John Ridges <jridges at masque.com> wrote:
>   
>> Sorry Benny, but it appears that pj_pool_alloc with a caching pool factory
>> still doesn't always return memory that is aligned properly when I have
>> PJ_POOL_ALIGNMENT set to 16. I haven't updated pjsip since I last reported
>> this bug, and when I got 1.5.5 I noticed that it didn't work. I fixed it by
>> aligning "block->cur" in pj_pool_create_int (for whatever that's worth).
>>
>>     
>
> That's what we've done too, see
> http://trac.pjsip.org/repos/changeset/2963. Do you see anything that
> should have been done differently?
>
> Cheers
>  Benny
>
>
>
>   
>   




[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux