代码复制有风险

程序原来支持IPv4,现在要支持IPv6,只有IP地址转换部分有区别,因此偷懒(时间也的确紧。。。)直接复制了原来代码修改,结果连续踩坑,v6好了,v4不能用了。。。

[DEBUG] &pgl:0x7ffef31e3868
[DEBUG] pgl:0x100a1a0 tid:0 rid:0 q:0x7ffef31e57c0 header:0x7fff7820262a msg:0x7ffef31e6110 rbuff:0x100e258 rbuff_len:0x7ffef31e5334 t:1489484783
[DEBUG] pgl->pgl:0x7ffe58df0010
[DEBUG]&(pgl->pgl->sp_lock):0x7ffe597fa0d8
[DEBUG] &pgl:0x7ffef31e3868
[DEBUG] &pgl:0x7ffef31e3868
[DEBUG] pgl:0x100a1a0 tid:0 rid:0 q:0x7ffef31e57c0 header:0x7fff7820262a msg:0x7ffef31e6110 rbuff:0x100e258 rbuff_len:0x7ffef31e5334 t:1489484783
[DEBUG] pgl->pgl:0x7ffe58df0010
[DEBUG]&(pgl->pgl->sp_lock):0x7ffe597fa0d8
[DEBUG]pthread_rwlock_unlock pgl:0x100a1a0
[DEBUG]pthread_rwlock_unlock pgl->pgl:0x7ffe58df0010
[DEBUG]pthread_rwlock_unlock &(pgl->pgl->sp_lock):0x7ffe597fa0d8
[DEBUG] &pgl:0x7ffef31e3868
[DEBUG] pgl:0x100a1a0 tid:0 rid:0 q:0x7ffef31e57c0 header:0x7fff782013aa msg:0x7ffef31e6110 rbuff:0x100e258 rbuff_len:0x7ffef31e5334 t:1489484783
[DEBUG] pgl->pgl:0x7ffe58df0010
[DEBUG]&(pgl->pgl->sp_lock):0x7ffe597fa0d8
[DEBUG] &pgl:0x7ffef31e3868
[DEBUG] &pgl:0x7ffef31e3868
[DEBUG] pgl:0x100a1a0 tid:0 rid:0 q:0x7ffef31e57c0 header:0x7fff782013aa msg:0x7ffef31e6110 rbuff:0x100e258 rbuff_len:0x7ffef31e5334 t:1489484783
[DEBUG] pgl->pgl:0x7ffe58df0010
[DEBUG]&(pgl->pgl->sp_lock):0x7ffe597fa0d8
[DEBUG]pthread_rwlock_unlock pgl:0x100a1a0
[DEBUG]pthread_rwlock_unlock pgl->pgl:0x7ffe58df0010
[DEBUG]pthread_rwlock_unlock &(pgl->pgl->sp_lock):0x7ffe597fa0d8
[DEBUG] &pgl:0x7ffef31e3868
[DEBUG] pgl:0x100a1a0 tid:0 rid:0 q:0x7ffef31e57c0 header:0x7fff78200a6a msg:0x7ffef31e6110 rbuff:0x100e258 rbuff_len:0x7ffef31e5334 t:1489484783
[DEBUG] pgl->pgl:0x7ffe58df0010
[DEBUG]&(pgl->pgl->sp_lock):0x7ffe597fa0d8
[DEBUG] &pgl:0x7ffef31e3868
[DEBUG] &pgl:0x653666363a2ebe

Program received signal SIGBUS, Bus error.
[Switching to Thread 0x7ffef31e7700 (LWP 38714)]
dns_f2c_process (pgl=<error reading variable: Cannot access memory at address 0x653666363a2ebe>, 
    pgl@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>, 
    tid=<error reading variable: Cannot access memory at address 0x653666363a2eba>, 
    tid@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>, 
    rid=<error reading variable: Cannot access memory at address 0x653666363a2eb6>, 
    rid@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>, 
    q=<error reading variable: Cannot access memory at address 0x653666363a2eae>, 
    q@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>, 
    header=<error reading variable: Cannot access memory at address 0x653666363a2ea6>, 
    header@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>, 
    msg=<error reading variable: Cannot access memory at address 0x653666363a2e9e>, 
    msg@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>, 
    rbuff=<error reading variable: Cannot access memory at address 0x653666363a3946>, 
    rbuff@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>, 
    rbuff_len=<error reading variable: Cannot access memory at address 0x653666363a394e>, 
    rbuff_len@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>, 
    t=<error reading variable: Cannot access memory at address 0x653666363a3956>, 
    t@entry=<error reading variable: Cannot access memory at address 0x653666363a393e>) at plug_dns_process.c:780
780		printf("[DEBUG] pgl:%p tid:%d rid:%d q:%p header:%p msg:%p rbuff:%p rbuff_len:%p t:%d\n",pgl, tid, rid, q, header, msg, rbuff, rbuff_len, t);
Missing separate debuginfos, use: debuginfo-install glibc-2.17-105.el7.x86_64
折腾了一天,通过笨方法,printf,夹逼到问题代码段,一眼就看出了问题

v4中原来是sp_value =(char*)inet_ntop(AF_INET,value,ip,48);

v6中是sp_value =(char*)inet_ntop(AF_INET6,value,ip,48);

结果修改v6的时候把v4也改成sp_value =(char*)inet_ntop(AF_INET6,value,ip,48);了


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值