possible bug?



hi, michael

   i notice that  there is a possible bug about alignment when demarshal  
GIOP request or reply.

   in function giop_send_buffer_align , the alignment is relative to 
message size not the buf address,  but in function 
giop_recv_buffer_demarshal_reply_1_x and  
giop_recv_buffer_demarshal_request_1_x , the alignment use the marco 
ALIGN_ADDRESS, which  operate on the absulate adress, so there my be some 
trouble when the g_malloc do with different alignment(for  
buf->message_body), e.g: one 8 bytes alignment and another 4 bytes 
alignment.in my example, the g_malloc(use kmalloc or vmalloc) in kernel 
always 4 bytes alignment, but in use space is 8 bytes aligment. so,use 
marco ALIGN_ADDRESS, there will be differen alignment result for a same 
request or replay.
   for example,  when marshal request, suppose buf->msg.header.message_size 
= 80, in function
giop_send_buffer_align (buf, 8)
{
        gulong align_amt, ms;

        /* 1. Figure out how much to align by */
        ms = buf->msg.header.message_size + buf->header_size;
        align_amt = ALIGN_VALUE(ms, boundary) - ms;
           .....
 align_amt  will be 4

    but in recv side, in function 
giop_recv_buffer_demarshal_reply_1_2(...), because buf->message_body is 4 
bytes aligment(by my g_malloc in kernel), for simple ,let us suppose it is 
0x00000004, before execute code ALIGN_ADDRESS(buf->cur,8), though buf->cur 
minus buf->message_body is 92 (/*80+12*/), the buf->cur is 92+4 = 0x60, so 
in this situation, the ALIGN_ADDRESS will __not make__ the buf->cur plus 4. 
it 's wrong.
   but if buf->message_body is 8 bytes aligment(by my g_malloc in use 
space), for simple ,let us suppose it is 0x00000008, before execute code 
ALIGN_ADDRESS(buf->cur,8), the buf->cur minus buf->message_body is 92 
(/*80+12*/), the buf->cur is 92+8 = 0x64, so in this situation, the 
ALIGN_ADDRESS will __make__ the buf->cur plus 4. it is right.

i suggest use a new function like this  to replace marco ALIGN_ADDRESS: 
void
giop_recv_buffer_align (GIOPRecvBuffer *buf, gulong boundary)
{
        gulong align_amt, ms;

        ms = buf->cur - buf->message_body;
        align_amt = ALIGN_VALUE(ms, boundary) - ms;
        if(align_amt)
           buf->cur += align_amt;
}

it have nothing with absulate address.

    best regards
                                               dou wen




_________________________________________________________________
Ãâ·ÑÏÂÔØ MSN Explorer£ºhttp://explorer.msn.com/lccn/intl.asp¡£




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