Error: invalid-allocation-alignment
Address Sanitizer Error: invalid-allocation-alignment
The _aligned_malloc
function requires a power of 2 for expressing the alignment. We simulate the "external" calculation of some alignment factor using an unoptimized global variable.
Example
// example1.cpp
// invalid-allocation-alignment error
#include <Windows.h>
int ExternalAlign = 5;
int main(){
// this externally calculated alignment of 5 isn't valid.
void* ptr = _aligned_malloc(8,ExternalAlign);
return (ptr == nullptr && errno == EINVAL) ? 0 : -1;
}
To build and test this example, run these commands in a Visual Studio 2019 version 16.9 or later developer command prompt:
cl example1.cpp /fsanitize=address /Zi
devenv /debugexe example1.exe
Resulting error
See also
AddressSanitizer overview
AddressSanitizer known issues
AddressSanitizer build and language reference
AddressSanitizer runtime reference
AddressSanitizer shadow bytes
AddressSanitizer cloud or distributed testing
AddressSanitizer debugger integration
AddressSanitizer error examples
Povratne informacije
https://aka.ms/ContentUserFeedback.
Stiže uskoro: Tijekom 2024. postupno ćemo ukinuti servis Problemi sa servisom GitHub kao mehanizam za povratne informacije za sadržaj i zamijeniti ga novim sustavom za povratne informacije. Dodatne informacije potražite u članku:Pošaljite i pogledajte povratne informacije za