Relative Content

Tag Archive for cmalloc

C memory leak warning

#include <stdio.h> #include <stdlib.h> int main() { int*** new = malloc(sizeof(int**)); *new = malloc(sizeof(int*)); **new = malloc(sizeof(int)); ***new = 2137; printf(“%in”, ***new); free(**new); free(*new); free(new); return EXIT_FAILURE; } This code, when compiled using command gcc -Wall -Wextra -fanalyzer -g -O0 -fsanitize=address,undefined -o test2 test2.c produces output: test2.c: In function ‘main’: test2.c:10:7: warning: leak of ‘malloc(4)’ […]

C memory leak warning

#include <stdio.h> #include <stdlib.h> int main() { int*** new = malloc(sizeof(int**)); *new = malloc(sizeof(int*)); **new = malloc(sizeof(int)); ***new = 2137; printf(“%in”, ***new); free(**new); free(*new); free(new); return EXIT_FAILURE; } This code, when compiled using command gcc -Wall -Wextra -fanalyzer -g -O0 -fsanitize=address,undefined -o test2 test2.c produces output: test2.c: In function ‘main’: test2.c:10:7: warning: leak of ‘malloc(4)’ […]

C memory leak warning

#include <stdio.h> #include <stdlib.h> int main() { int*** new = malloc(sizeof(int**)); *new = malloc(sizeof(int*)); **new = malloc(sizeof(int)); ***new = 2137; printf(“%in”, ***new); free(**new); free(*new); free(new); return EXIT_FAILURE; } This code, when compiled using command gcc -Wall -Wextra -fanalyzer -g -O0 -fsanitize=address,undefined -o test2 test2.c produces output: test2.c: In function ‘main’: test2.c:10:7: warning: leak of ‘malloc(4)’ […]

C memory leak warning

#include <stdio.h> #include <stdlib.h> int main() { int*** new = malloc(sizeof(int**)); *new = malloc(sizeof(int*)); **new = malloc(sizeof(int)); ***new = 2137; printf(“%in”, ***new); free(**new); free(*new); free(new); return EXIT_FAILURE; } This code, when compiled using command gcc -Wall -Wextra -fanalyzer -g -O0 -fsanitize=address,undefined -o test2 test2.c produces output: test2.c: In function ‘main’: test2.c:10:7: warning: leak of ‘malloc(4)’ […]

C memory leak warning

#include <stdio.h> #include <stdlib.h> int main() { int*** new = malloc(sizeof(int**)); *new = malloc(sizeof(int*)); **new = malloc(sizeof(int)); ***new = 2137; printf(“%in”, ***new); free(**new); free(*new); free(new); return EXIT_FAILURE; } This code, when compiled using command gcc -Wall -Wextra -fanalyzer -g -O0 -fsanitize=address,undefined -o test2 test2.c produces output: test2.c: In function ‘main’: test2.c:10:7: warning: leak of ‘malloc(4)’ […]

LLVM Address Sanitizer vs. `MALLOC_CHECK_=3`

In our CI jobs for our C++ project we run tests under both Address Sanitizer and MALLOC_CHECK_=3. I’m beginning to wonder whether the latter is even necessary. There are rumors flying around that the latter might check memory errors that ASan cannot, but I’m skeptical. For example, I heard that: “ASan can’t figure out that you stomped over the allocator’s private data structures.”