可能由_wordcopy_fwd_dest_aligned 引起的一处内存出错

17 篇文章 0 订阅
 ==28356== Thread 9:
1481 ==28356== Invalid read of size 8
1482 ==28356==    at 0x3328A7BA95: _wordcopy_fwd_dest_aligned (in /lib64/libc-2.5.so)
1483 ==28356==    by 0x3328A7B0FF: bcopy (in /lib64/libc-2.5.so)
1484 ==28356==    by 0x5E3C45: unsigned int CSocket::packetPackZip<ByteBuffer<unsigned char [65560]> >(void const*, unsigned int, ByteBuffer<unsigned char [65560]>&, bool) 

        这是通过memcheck检查到的一个内存读错误,

        发现可能是因为 _wordcopy_fwd_dest_aligned 偏移对齐的操作引起的

http://www.oschina.net/code/explore/glibc-2.9/sysdeps/powerpc/powerpc32/power4/wordcopy.c

/** _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
064    block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
065    DSTP should be aligned for memory operations on `op_t's, but SRCP must
066    *not* be aligned.  */
067  
068 void
069 _wordcopy_fwd_dest_aligned (dstp, srcp, len)
070      long int dstp;
071      long int srcp;
072      size_t len;
073 {
074   op_t a0, a1, a2;
075   int sh_1, sh_2;
076  
077   /** Calculate how to shift a word read at the memory operation
078      aligned srcp to make it aligned for copy.  */
079  
080   sh_1 = 8 * (srcp % OPSIZ);
081   sh_2 = 8 * OPSIZ - sh_1;
082  
083   /** Make SRCP aligned by rounding it down to the beginning of the `op_t'
084      it points in the middle of.  */
085   srcp &= -OPSIZ;
086   a0 = ((op_t *) srcp)[0];
087  
088   if (len & 1)
089   {
090     a1 = ((op_t *) srcp)[1];
091     ((op_t *) dstp)[0] = MERGE (a0, sh_1, a1, sh_2);
092      
093     if (len == 1)
094       return;
095      
096     a0 = a1;
097     srcp += OPSIZ;
098     dstp += OPSIZ;
099     len -= 1;
100   }
101  
102   do
103     {
104       a1 = ((op_t *) srcp)[1];
105       a2 = ((op_t *) srcp)[2];
106       ((op_t *) dstp)[0] = MERGE (a0, sh_1, a1, sh_2);
107       ((op_t *) dstp)[1] = MERGE (a1, sh_1, a2, sh_2);
108       a0 = a2;
109  
110       srcp += 2 * OPSIZ;
111       dstp += 2 * OPSIZ;
112       len -= 2;
113     }
114   while (len != 0);
115 }
              暂时没有想到很好的解决方案,先用memmove 代替 bcopy

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值