unnoticed invalid dereference when using address sanitizer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

the code below has been compiled with GCC 5.3:

$ gcc -fsanitize=3Daddress -fno-omit-frame-pointer -g sanitize.c

When executing the result, the sanitizer only complains about the
invalid dereference of the second printf statement, while the first
one is executed unnoticed.

Did I encounter a gcc bug in the address sanitizer, or is this intended
behavior? If it is a bug, is there a related bug report already?

Thanks for any help,

Chris

#include <stdlib.h>
#include <stdio.h>

struct Simple {
    int value;
};
int f(struct Simple simple) {
    return simple.value;
}

int g(int value) {
    return value;
}

int main() {

    struct Simple *psimple = (struct Simple *) malloc(sizeof(struct Simple));
    psimple->value = 42;
    free(psimple);
    printf("%d\n", f(*psimple));

    int *pint = (int *) malloc(sizeof(int));
    *pint = 24;
    free(pint);
    printf("%d\n", g(*pint));

    return 0;
}




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux