오류: allocation-size-too-big
삭제자 오류 해결: allocation-size-too-big
이 예제에서는 할당이 힙에 대해 너무 큰 경우 발견된 오류를 보여 드립니다. LLVM 컴파일러-rt 테스트 도구 모음에서 원본이 된 예제입니다.
예시
// example1.cpp
// allocation-size-too-big error
#include <stdio.h>
#include <malloc.h>
#include <memory.h>
int x = 1000;
int y = 1000;
__declspec(noinline) void bad_function() {
char* buffer = (char*)malloc(x * y * x * y); //Boom!
memcpy(buffer, buffer + 8, 8);
}
int main(int argc, char **argv) {
bad_function();
return 0;
}
이 예제를 빌드하고 테스트하려면 Visual Studio 2019 버전 16.9 이상 개발자 명령 프롬프트에서 다음 명령을 실행합니다.
cl example1.cpp /fsanitize=address /Zi
devenv /debugexe example1.exe
결과 오류
참고 항목
AddressSanitizer 개요
AddressSanitizer 알려진 문제
AddressSanitizer 빌드 및 언어 참조
AddressSanitizer 런타임 참조
AddressSanitizer 섀도 바이트
AddressSanitizer 클라우드 또는 분산 테스트
AddressSanitizer 디버거 통합
AddressSanitizer 오류 예제