From db825ceba694eb6abe4ecff45fc4e1121646385f Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 30 Jul 2019 15:27:39 +0900 Subject: [PATCH] Don't fail if default namespace isn't found This fixes a regression caused by 8f4afc8298ebae34e8f944a0807943997908c67d that libnativeloader can't no longer handle the case that it has failed to find the default namespace. Previously before the change, libnativeloader continued to use nullptr as the parent namespace which is reconized as the default namespace inside the linker. This change recovers the previous behavior. When the default namespace is not found, NativeLoaderNamespace object is constructed from nullptr. Bug: 138607234 Test: run app-compat/app-startup-gce on cf_x86_phone using forrest Change-Id: If518fbc055399b73e7d3a6b45ace0f71e9c25dae --- libnativeloader/native_loader_namespace.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libnativeloader/native_loader_namespace.cpp b/libnativeloader/native_loader_namespace.cpp index 4b0211670..4add6e690 100644 --- a/libnativeloader/native_loader_namespace.cpp +++ b/libnativeloader/native_loader_namespace.cpp @@ -69,10 +69,18 @@ Result NativeLoaderNamespace::GetExportedNamespace(const // "default" always exists. Result NativeLoaderNamespace::GetPlatformNamespace(bool is_bridged) { auto ns = GetExportedNamespace(kPlatformNamespaceName, is_bridged); - if (!ns) { - ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged); + if (ns) return ns; + ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged); + if (ns) return ns; + + // If nothing is found, return NativeLoaderNamespace constructed from nullptr. + // nullptr also means default namespace to the linker. + if (!is_bridged) { + return NativeLoaderNamespace(kDefaultNamespaceName, static_cast(nullptr)); + } else { + return NativeLoaderNamespace(kDefaultNamespaceName, + static_cast(nullptr)); } - return ns; } Result NativeLoaderNamespace::Create(