heap-buffer-overflow(越界访问)
uint32_t val[10] = {0};
val[10] = 10;
一版造成这种问题的原因是访问了没有申请的内存,栈上的,或者堆上的。
heap-use-after-free(使用被释放的资源)
多线程:
=================================================================
==79237==ERROR: AddressSanitizer: heap-use-after-free on address 0x62d00f0dd7c8 at pc 0x1a238a3 bp 0x7f59cb36ed00 sp 0x7f59cb36ecf8
READ of size 8 at 0x62d00f0dd7c8 thread T1027
0x62d00f0dd7c8 is located 5064 bytes inside of 34328-byte region [0x62d00f0dc400,0x62d00f0e4a18)
freed by thread T910 here:
previously allocated by thread T910 here:
Thread T1027 created by T910 here:
Thread T910 created by T0 here:
SUMMARY: AddressSanitizer: heap-use-after-free
以上是ASAN保存的相关信息(具体栈信息脱敏处理了),错误类型heap-use-after-free。
从以上信息分析,线程T1027使用了释放后的内存,再看Thread T1027 created by T910,这种问题就很容易得出结论,主线程结束了,释放了相关资源,然而子进程尚未结束,因此才会造成这个问题。一般出现这个问题的真正原因,是主线程创建了多个子线程,其中一个子线程提前结束,而主线程判断返回结果后也直接退出了,其他线程尚未结束。