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

Commit bbc2914b authored by Dongwon Kang's avatar Dongwon Kang Committed by android-build-merger
Browse files

Merge "Make tombstone in the child process on loading failure." into qt-dev

am: da35a430

Change-Id: I78f16b6fa4087f52ec50f23be256819e7e73e5ba
parents a444666e da35a430
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <C2Config.h>
#include <C2PlatformStorePluginLoader.h>
#include <C2PlatformSupport.h>
#include <media/stagefright/foundation/ADebug.h>
#include <util/C2InterfaceHelper.h>

#include <dlfcn.h>
@@ -661,31 +662,37 @@ c2_status_t C2PlatformComponentStore::ComponentModule::init(
    ALOGV("in %s", __func__);
    ALOGV("loading dll");
    mLibHandle = dlopen(libPath.c_str(), RTLD_NOW|RTLD_NODELETE);
    LOG_ALWAYS_FATAL_IF(mLibHandle == nullptr,
            "could not dlopen %s: %s", libPath.c_str(), dlerror());
    if (mLibHandle == nullptr) {
        LOG_ALWAYS_FATAL_IN_CHILD_PROC("could not dlopen %s: %s", libPath.c_str(), dlerror());
        mInit = C2_CORRUPTED;
        return mInit;
    }

    createFactory =
        (C2ComponentFactory::CreateCodec2FactoryFunc)dlsym(mLibHandle, "CreateCodec2Factory");
    LOG_ALWAYS_FATAL_IF(createFactory == nullptr,
            "createFactory is null in %s", libPath.c_str());
    if (createFactory == nullptr) {
        LOG_ALWAYS_FATAL_IN_CHILD_PROC("createFactory is null in %s", libPath.c_str());
        mInit = C2_CORRUPTED;
        return mInit;
    }

    destroyFactory =
        (C2ComponentFactory::DestroyCodec2FactoryFunc)dlsym(mLibHandle, "DestroyCodec2Factory");
    LOG_ALWAYS_FATAL_IF(destroyFactory == nullptr,
            "destroyFactory is null in %s", libPath.c_str());
    if (destroyFactory == nullptr) {
        LOG_ALWAYS_FATAL_IN_CHILD_PROC("destroyFactory is null in %s", libPath.c_str());
        mInit = C2_CORRUPTED;
        return mInit;
    }

    mComponentFactory = createFactory();
    if (mComponentFactory == nullptr) {
        ALOGD("could not create factory in %s", libPath.c_str());
        mInit = C2_NO_MEMORY;
    } else {
        mInit = C2_OK;
    }

    if (mInit != C2_OK) {
        return mInit;
    }

    mInit = C2_OK;

    std::shared_ptr<C2ComponentInterface> intf;
    c2_status_t res = createInterface(0, &intf);
    if (res != C2_OK) {
+16 −12
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@
#include <utils/Log.h>

#include <android/dlext.h>
#include <android-base/logging.h>
#include <binder/IPCThreadState.h>
#include <binder/PermissionCache.h>
#include <binder/IServiceManager.h>
#include <media/DataSource.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/InterfaceUtils.h>
#include <media/stagefright/MediaExtractor.h>
#include <media/stagefright/MediaExtractorFactory.h>
@@ -245,17 +245,21 @@ void MediaExtractorFactory::RegisterExtractors(
            void *libHandle = android_dlopen_ext(
                    libPath.string(),
                    RTLD_NOW | RTLD_LOCAL, dlextinfo);
            CHECK(libHandle != nullptr)
                    << "couldn't dlopen(" << libPath.string() << ") " << strerror(errno);

            if (libHandle) {
                GetExtractorDef getDef =
                    (GetExtractorDef) dlsym(libHandle, "GETEXTRACTORDEF");
            CHECK(getDef != nullptr)
                    << libPath.string() << " does not contain sniffer";

                if (getDef) {
                    ALOGV("registering sniffer for %s", libPath.string());
                    RegisterExtractor(
                            new ExtractorPlugin(getDef(), libHandle, libPath), pluginList);
                } else {
                    LOG_ALWAYS_FATAL_IN_CHILD_PROC("%s does not contain sniffer", libPath.string());
                    dlclose(libHandle);
                }
            } else {
                LOG_ALWAYS_FATAL_IN_CHILD_PROC(
                        "couldn't dlopen(%s) %s", libPath.string(), strerror(errno));
            }
        }
        closedir(libDir);
    } else {
+9 −0
Original line number Diff line number Diff line
@@ -123,6 +123,15 @@ inline static const char *asString(status_t i, const char *def = "??") {
#define TRESPASS_DBG(...)
#endif

#ifndef LOG_ALWAYS_FATAL_IN_CHILD_PROC
#define LOG_ALWAYS_FATAL_IN_CHILD_PROC(...)   \
    do {                                      \
        if (fork() == 0) {                    \
            LOG_ALWAYS_FATAL(__VA_ARGS__);    \
        }                                     \
    } while (false)
#endif

struct ADebug {
    enum Level {
        kDebugNone,             // no debug