Skip to content

Missing ASAN Interceptor for mempcpy #148917

@mvanotti

Description

@mvanotti

It looks like there's no ASAN interceptor for mempcpy.

Typically, by default clang will treat mempcpy as a built-in function, and replace it by memcpy, which would then be replaced by __asan_memcpy.

However, if the user specifies a flag like -std=c++20, mempcpy will no longer be treated as a built-in and will not get any kind of asan instrumentation.

The following C++ program crashes when compiled with -O0 -fsanitize=address but fails when compiled with -O0 -fsanitize=address -std=c++20

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

char buffer[1024] = {0};

int main(void) {
    void* data = malloc(1020);
    mempcpy(data, buffer, 1024);
    free(data);
    return 0;
}

See in godbolt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions