内存的非法读写操作的检查

 

valgrind什么的就不说了

 

AddressSanitizer

除了heap,stack的也可以

https://en.wikipedia.org/wiki/AddressSanitizer#Stack-buffer-overflow

http://developerblog.redhat.com/2014/12/02/address-and-thread-sanitizers-gcc/

 

 

tcmalloc的page fence

局限是只能对heap做越界读写的检查

http://www.xuebuyuan.com/1466812.html

 

  http://gperftools.googlecode.com/files/gperftools-2.0.tar.gz

    修改了代码,打开了内存越界检查的文件。修改如下:

    sed -i "s/EnvToBool(\"TCMALLOC_PAGE_FENCE\", false)/EnvToBool(\"TCMALLOC_PAGE_FENCE\", true)/g" src/debugallocation.cc
    意思是:
            src/debugallocation.cc: 101
                    DEFINE_bool(malloc_page_fence,
                                EnvToBool("TCMALLOC_PAGE_FENCE", false),
                                "Enables putting of memory allocations at page boundaries "
                                "with a guard page following the allocation (to catch buffer "
                                "overruns right when they happen).");
            将
                EnvToBool("TCMALLOC_PAGE_FENCE", false)
            改成了
                EnvToBool("TCMALLOC_PAGE_FENCE", true)

        cd gperftools-2.0 && ./configure --enable-frame-pointers && make

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值