0x00007ffff7ade419 in memcpy () from /lib/libc.so.6

先看gdb跟踪过程

Hardware watchpoint 3: pad_front


Old value = 4
New value = 15
breath_travel (pRoot=0x603030, pQueue=0x603010) at print_tree_final.c:206
206         if((qNode->blank == 1))
(gdb) n
228            if(pad_front == 0)   
(gdb) n
235                   char *old_buf=buf_branch;
(gdb) n
236                   printf("%*s%*d%*s",pad_front*pad_num," ",pad_num,qNode->t_node->value,(1+pad_front)*pad_num," ");
(gdb) n
238                   sprintf(new_buf,"%s","123");
(gdb) n
Hardware watchpoint 2: child_depth

Old value = 2
New value = 3355185
0x00007ffff7ade419 in memcpy () from /lib/libc.so.6


我很奇怪,为啥int child = 2的值会被sprintf语句改写,一直想不明白。搜索了下,发现new_buf没分配空间造成的,所以才会说memcpy内存复制错误,可能覆盖了其它数据区域。

我声明 new_buf方法是

char *new_buf;

改为

char *new_buf=(char*)malloc(100);

问题解决。怪不得数组初始化经常是

char buffer[1024];

这样的。应该是等同上面那句malloc语句。如果指针和数组没有初始化,就很可能覆盖了其它区域。


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Casola, V., & Castiglione, A. (2020). Secure and Trustworthy Big Data Storage. Springer. Corriveau, D., Gerrish, B., & Wu, Z. (2020). End-to-end Encryption on the Server: The Why and the How. arXiv preprint arXiv:2010.01403. Dowsley, R., Nascimento, A. C. A., & Nita, D. M. (2021). Private database access using homomorphic encryption. Journal of Network and Computer Applications, 181, 103055. Hossain, M. A., Fotouhi, R., & Hasan, R. (2019). Towards a big data storage security framework for the cloud. In Proceedings of the 9th Annual Computing and Communication Workshop and Conference (CCWC), Las Vegas, USA (pp. 402-408). Rughani, R. (2019). Analysis of Security Issues and Their Solutions in Cloud Storage Environment. International Journal of Computer Trends and Technology (IJCTT), 67(6), 37-42. van Esbroeck, A. (2019). Zero-Knowledge Proofs in the Age of Cryptography: Preventing Fraud Without Compromising Privacy. Chicago-Kent Journal of Intellectual Property, 19, 374. Berman, L. (2021). Watch out for hidden cloud costs. CFO Dive. Retrieved from https://www.cfodive.com/news/watch-out-for-hidden-cloud-costs/603921/ Bradley, T. (2021). Cloud storage costs continue to trend downward. Forbes. Retrieved from https://www.forbes.com/sites/tonybradley/2021/08/27/cloud-storage-costs-continue-to-trend-downward/?sh=6f9d6ade7978 Cisco. (2019). Cost optimization in the multicloud. Cisco. Retrieved from https://www.cisco.com/c/dam/en/us/solutions/collateral/data-center-virtualization/cloud-cost-optimization/cost-optimization_in_multicloud.pdf IBM. (2020). Storage efficiency solutions. IBM. Retrieved from https://www.ibm.com/blogs/systems/storage-efficiency-solutions/ Microsoft Azure. (n.d.). Azure Blob storage tiers. Microsoft Azure. Retrieved from https://azure.microsoft.com/en-us/services/storage/blobs/#pricing Nawrocki, M. (2019). The benefits of a hybrid cloud strategy for businesses. DataCenterNews. Retrieved from https://datacenternews.asia/story/the-benefits-of-a-hybrid-cloud-strategy-for,请把这一段reference list改为标准哈佛格式
05-29

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值