代码复制有风险

来源:互联网 发布:mac系统重装教程 编辑:程序博客网 时间:2024/04/28 12:55

程序原来支持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:0x653666363a2ebeProgram 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:780780printf("[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);了


0 0