Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASAN fails to catch UAF on compound literal #124413

Open
Alcaro opened this issue Jan 25, 2025 · 1 comment
Open

ASAN fails to catch UAF on compound literal #124413

Alcaro opened this issue Jan 25, 2025 · 1 comment
Labels

Comments

@Alcaro
Copy link
Contributor

Alcaro commented Jan 25, 2025

#include <stdio.h>

int main(void) {
    int *xs[5] = {0};

    for (int i = 0; i < 5; ++i) {
        xs[i] = &(int){42};
    }

    for (int i = 0; i < 5; ++i) {
        printf("%p = %d\n", xs[i], *xs[i]);
    }
}

-fsanitize=address

GCC complains, Clang doesn't. https://godbolt.org/z/Phqh9fGsj

(Not mine, @Garciat posted it on godbolt discord and asked if it's UB.)

@vitalybuka
Copy link
Collaborator

Looking at IR, clang does not generate lifetime markers for this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants