When using Address Sanitizer when either of ASAN or the actual program fails, the exitcode is always 1. How can I differentiate one from the other? I tried setting exitcode option in ASAN_OPTIONS to something other than 1, but still ASAN is exiting with 1. What can I do?
Here is the sample code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, const char *argv[]) {
char *s = malloc(5);
strcpy(s, "Hello world!");
printf("string is: %s\n", s);
//free(s);
return 0;
}
Here is the command used to compile:
gcc -g -fsanitize=address -o /tmp/tmp.bin /tmp/tmp.c
Here is the command used to execute:
ASAN_OPTIONS=exitcode=0 /tmp/tmp.bin ; echo $?
Here whatever exitcode I used (other than 0), I'm getting 1 as output of echo $?
1?exitcode=123, it returns123for me. Usinggcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0