c++address-sanitizersanitizer

ASAN does not detect buffer overflow


There is the following piece of code

#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 does not detect buffer overflow

Code sample https://godbolt.org/z/r34f9jexj


Solution

  • It looks like sanitisation of thread_local global variables hasn't been implemented yet https://github.com/google/sanitizers/issues/12