Revert "Fix bug with double unload on unsuccessful dlopen"
This reverts commit 58554ccb8ac27fd3b5693efde2e1f7ab2a895ea2.
causes /vendor/bin/qseecomd to hit the new abort:
[ 8.983301] c5 603 DEBUG: Abort message: 'soinfo=0x7147894cd0 is not in soinfo_list (double unload?)'
Bug: http://b/69909887
Bug: http://b/69787209
Change-Id: Ied38f797e0a071a1acc5ed41adf1b45e855143c7
diff --git a/linker/linker.cpp b/linker/linker.cpp
index f1ef557..85376e0 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -321,7 +321,9 @@
TRACE("name %s: freeing soinfo @ %p", si->get_realpath(), si);
if (!solist_remove_soinfo(si)) {
- async_safe_fatal("soinfo=%p is not in soinfo_list (double unload?)", si);
+ // TODO (dimitry): revisit this - for now preserving the logic
+ // but it does not look right, abort if soinfo is not in the list instead?
+ return;
}
// clear links to/from si
@@ -1518,6 +1520,11 @@
}
});
+ auto failure_guard = android::base::make_scope_guard([&]() {
+ // Housekeeping
+ soinfo_unload(soinfos, soinfos_count);
+ });
+
ZipArchiveCache zip_archive_cache;
// Step 1: expand the list of load_tasks to include
@@ -1682,6 +1689,8 @@
si->set_linked();
}
});
+
+ failure_guard.Disable();
}
return linked;
@@ -1691,7 +1700,7 @@
const char* name, int rtld_flags,
const android_dlextinfo* extinfo,
soinfo* needed_by) {
- soinfo* si = nullptr;
+ soinfo* si;
// readers_map is shared across recursive calls to find_libraries.
// However, the map is not shared across different threads.
@@ -1710,9 +1719,6 @@
false /* add_as_children */,
true /* search_linked_namespaces */,
readers_map)) {
- if (si != nullptr) {
- soinfo_unload(si);
- }
return nullptr;
}