#asan 链接sys set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") SET(CMAKE_C_FLAGS_ASAN "-O2 -g -fsanitize=address -fno-omit-frame-pointer" CACHE STRING "Flags used by the C compiler during asan builds." FORCE) SET(CMAKE_C_FLAGS "-O2 -g -fsanitize=address -fno-omit-frame-pointer -lstdc++ -lasan" CACHE STRING "Flags used by the C compiler during asan builds." FORCE)
==1867==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f69c0e59823 at pc 0x000001f1f50c bp 0x7f69c02624e0 sp 0x7f69c02624d0 ... 0x7f69c0e59823 is located 35 bytes inside of 8388608-byte region [0x7f69c0e59800,0x7f69c1659800) freed by thread T14 here: ... previously allocated by thread T14 here: ... SUMMARY: AddressSanitizer: heap-use-after-free /data/zhenkai.sun/ranker/cmake-build-debug/CMakeUnzipPackages/mongo-c-driver-1.19.1/src/libbson/src/bson/bson.c:1993 in bson_init_static Shadow bytes around the buggy address: 0x0fedb81c32b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0fedb81c32c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0fedb81c32d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0fedb81c32e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0fedb81c32f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x0fedb81c3300: fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3310: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3320: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3330: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3340: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0fedb81c3350: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==1867==ABORTING