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

Commit b47712a9 authored by Christopher Ferris's avatar Christopher Ferris
Browse files

Move codec and extractor to libc_scudo.

The mediaswcodec and mediaextractor use the scudo libraries as a
sanitizer. This has some downsides since it bypasses all of the normal
allocation handlers used by the rest of the system.

Switching from the plain sanitizer to a wrapper library libc_scudo.so
allows the use of the allocation handler code from
bionic/libc/bionic/malloc_common.cpp.

This is a temporary workaround, later versions of Android should
support scudo as a first class native allocator.

NOTE: The two libraries that make up the scudo override combined are
smaller than the libclang_rt.scudo-XXX.so library, so this is a space
win too.

Bug: 123689570

Test: Builds and boots. Verified that scudo is used as the allocator.
Test: Verified that the allocation limit is properly set for mediaextractor.
Test: Ran a few of the CtsMediaTestCases tests.

Change-Id: I3bdf76bfeea503b33da765e093e38818b620a481
parent ba9a0506
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -20,6 +20,15 @@ cc_binary {
            exclude_shared_libs: ["libavservices_minijail"],
            shared_libs: ["libavservices_minijail_vendor"],
        },
        android: {
            product_variables: {
                malloc_not_svelte: {
                    // Scudo increases memory footprint, so only enable on
                    // non-svelte devices.
                    shared_libs: ["libc_scudo"],
                },
            },
        },
    },

    header_libs: [
@@ -35,10 +44,6 @@ cc_binary {
        "-Wall",
        "-Wno-error=deprecated-declarations",
    ],

    sanitize: {
        scudo: true,
    },
}

prebuilt_etc {
+0 −6
Original line number Diff line number Diff line
@@ -31,12 +31,6 @@ static const char kSystemSeccompPolicyPath[] =
static const char kVendorSeccompPolicyPath[] =
        "/vendor/etc/seccomp_policy/mediaswcodec.policy";

// Disable Scudo's mismatch allocation check, as it is being triggered
// by some third party code.
extern "C" const char *__scudo_default_options() {
    return "DeallocationTypeMismatch=false";
}

extern "C" void RegisterCodecServices();

int main(int argc __unused, char** /*argv*/)
+5 −2
Original line number Diff line number Diff line
@@ -20,13 +20,16 @@ LOCAL_REQUIRED_MODULES_x86 := crash_dump.policy mediaextractor.policy
LOCAL_REQUIRED_MODULES_x86_64 := crash_dump.policy mediaextractor.policy

LOCAL_SRC_FILES := main_extractorservice.cpp
LOCAL_SHARED_LIBRARIES := libmedia libmediaextractorservice libbinder libutils \
ifneq (true, $(filter true, $(MALLOC_SVELTE)))
# Scudo increases memory footprint, so only use on non-svelte configs.
LOCAL_SHARED_LIBRARIES := libc_scudo
endif
LOCAL_SHARED_LIBRARIES += libmedia libmediaextractorservice libbinder libutils \
    liblog libandroidicu libavservices_minijail
LOCAL_MODULE:= mediaextractor
LOCAL_INIT_RC := mediaextractor.rc
LOCAL_C_INCLUDES := frameworks/av/media/libmedia
LOCAL_CFLAGS := -Wall -Werror
LOCAL_SANITIZE := scudo
include $(BUILD_EXECUTABLE)

# service seccomp filter
+0 −6
Original line number Diff line number Diff line
@@ -41,12 +41,6 @@ static const char kSystemSeccompPolicyPath[] =
static const char kVendorSeccompPolicyPath[] =
        "/vendor/etc/seccomp_policy/mediaextractor.policy";

// Disable Scudo's mismatch allocation check, as it is being triggered
// by some third party code.
extern "C" const char *__scudo_default_options() {
    return "DeallocationTypeMismatch=false";
}

int main(int argc __unused, char** argv)
{
    limitProcessMemory(