ASAN 未检测到缓冲区溢出

问题描述 投票:0回答:1

有下面一段代码

#include <iostream>
#include <type_traits>
thread_local std::aligned_storage_t<1024> data;
int main() {
    std::cout << sizeof(data) << std::endl;
    uint8_t * d = new (&data) uint8_t[1024];
    d[1025] = '6';
    std::cout << d[1025] << std::endl;
}

Sanitiser 无法检测缓冲区溢出

代码示例 https://godbolt.org/z/r34f9jexj

c++ address-sanitizer sanitizer
1个回答
1
投票

看起来

thread_local
全局变量的清理尚未实现https://github.com/google/sanitizers/issues/12

© www.soinside.com 2019 - 2024. All rights reserved.