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
diff --git a/services/mediacodec/Android.bp b/services/mediacodec/Android.bp
index 25c36fa..32d2fde 100644
--- a/services/mediacodec/Android.bp
+++ b/services/mediacodec/Android.bp
@@ -20,6 +20,15 @@
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 @@
"-Wall",
"-Wno-error=deprecated-declarations",
],
-
- sanitize: {
- scudo: true,
- },
}
prebuilt_etc {
diff --git a/services/mediacodec/main_swcodecservice.cpp b/services/mediacodec/main_swcodecservice.cpp
index c44be28..a5db031 100644
--- a/services/mediacodec/main_swcodecservice.cpp
+++ b/services/mediacodec/main_swcodecservice.cpp
@@ -31,12 +31,6 @@
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*/)
diff --git a/services/mediaextractor/Android.mk b/services/mediaextractor/Android.mk
index fd34d5b..9db6ed1 100644
--- a/services/mediaextractor/Android.mk
+++ b/services/mediaextractor/Android.mk
@@ -20,13 +20,16 @@
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
diff --git a/services/mediaextractor/main_extractorservice.cpp b/services/mediaextractor/main_extractorservice.cpp
index 06b532d..bb9a56b 100644
--- a/services/mediaextractor/main_extractorservice.cpp
+++ b/services/mediaextractor/main_extractorservice.cpp
@@ -41,12 +41,6 @@
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(