前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >记一个AddressSanitizer(ASAN)linux下的内存分析神器的问题

记一个AddressSanitizer(ASAN)linux下的内存分析神器的问题

作者头像
杨永贞
发布2020-08-04 11:11:57
6980
发布2020-08-04 11:11:57
举报

感谢万能的互联网,我向google提出的issue很快就得到了工程师回复,解决了我的问题。

我的问题是这样的:

AddressSanitizer can't detect some global buffer overflow!  #1285

Closed

yangyongzhen opened this issue yesterday · 1 comment

yangyongzhen commented yesterday

what a pity! AddressSanitizer can't detect some global buffer overflow! Even if the mistake or code bugs is so obvious。 for example,this code bellow, guess what you will get, ...... U08 IP[10]; U08 IP1[10]; int main() { memset(IP1,0x3A,10); memcpy(IP,"123456789021111111111",17); IP[15] = 12; printf("IP1[0]:%d\n",IP1[0]); printf("IP1[1]:%d\n",IP1[1]); printf("IP1[2]:%d\n",IP1[2]); printf("IP[10]:%d\n",IP[10]); printf("IP[11]:%d\n",IP[11]); printf("IP[15]:%d\n",IP[15]); printf("IP1[0]:%d\n",IP1[0]); printf("IP1[1]:%d\n",IP1[1]); printf("IP1[2]:%d\n",IP1[2]); } 。。。。。。 use cflags= -std=gnu99 -Wall -fno-stack-protector -fno-omit-frame-pointer -fvar-tracking -g2 -fno-inline -fsanitize=address -fexceptions but AddressSanitizer can't detect this!!! if you add "static" before the global vars,like this: static U08 IP[10]; then AddressSanitizer can detect mistakes,, why?

melver commented 23 hours ago

Add -fno-common for C code. Globals that are placed in the common section (default for C) won't be separated by redzones, and therefore the OOB accesses in your example simply access IP1's memory.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-07-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • AddressSanitizer can't detect some global buffer overflow!  #1285
    • yangyongzhen commented yesterday
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档