Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1005323 authored by Jeff Vander Stoep's avatar Jeff Vander Stoep Committed by Jeffrey Vander Stoep
Browse files

mediaextractor: Skip setting memory limits on ASan builds

ASan-ified libraries have a larger memory footprint which counts
towards a process's RLIMIT_AS. Detect ASan at runtime and skip
setting memory limits.

Test: Builds and boots. "MediaUtils: running with ASan, not setting
memory limits" appears in logcat, mediaextractor is no longer
crashing.

(cherry picked from commit 4bc7ad9e)

Bug: 31831213
Change-Id: I6705baa825cbfd45695def2cd80d8d2261b05339
parent 84404f06
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ void limitProcessMemory(
    size_t numberOfBytes,
    size_t percentageOfTotalMem) {

    if (running_with_asan()) {
        ALOGW("Running with ASan, skip enforcing memory limitations.");
        return;
    }

    long pageSize = sysconf(_SC_PAGESIZE);
    long numPages = sysconf(_SC_PHYS_PAGES);
    size_t maxMem = SIZE_MAX;
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,12 @@

namespace android {

extern "C" void __asan_init(void) __attribute__((weak));

static inline int running_with_asan() {
    return &__asan_init != 0;
}

/**
   Limit the amount of memory a process can allocate using setrlimit(RLIMIT_AS).
   The value to use will be read from the specified system property, or if the