From 79694d5d0a632ed4ca04ea42f19fb09c3fba0cdb Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Thu, 3 Jul 2014 22:30:44 +0200 Subject: Delete subsystem instances *before* plugin unload BZ: 208504 Before this patch there was a crash in CElement destructor in Ubuntu upon destuction of parameter framework instance. The crash was caused by the attempt to call unmapped code: The subsystem plugin libraries were getting unloaded before the execution of the subsystem destructors. Note: In Android the issue is not seen since library unload is not implemented. This patch ensures SystemClass destructor destroys the subsystems explicitely unloading the plugins. Change-Id: I19dad262b384bdbd63c7c319a41a5d547d0e75e9 Signed-off-by: Patrick Benavoli --- parameter/SystemClass.cpp | 17 +++++++++++------ parameter/SystemClass.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'parameter') diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp index effc573..6169223 100644 --- a/parameter/SystemClass.cpp +++ b/parameter/SystemClass.cpp @@ -71,11 +71,16 @@ CSystemClass::~CSystemClass() { delete _pSubsystemLibrary; - // Close all previously opened libraries - while (!_subsystemLibraries.empty()) - { - dlclose(_subsystemLibraries.back()); - _subsystemLibraries.pop_back(); + // Destroy child subsystems *before* unloading the libraries (otherwise crashes will occur + // as unmapped code will be referenced) + clean(); + + // Close all previously opened subsystem libraries + list::const_iterator it; + + for (it = _subsystemLibraryHandleList.begin(); it != _subsystemLibraryHandleList.end(); ++it) { + + dlclose(*it); } } @@ -238,7 +243,7 @@ bool CSystemClass::loadPlugins(list& lstrPluginFiles, list& lstr } // Store libraries handles - _subsystemLibraries.push_back(lib_handle); + _subsystemLibraryHandleList.push_back(lib_handle); // Get plugin symbol string strPluginSymbol = getPluginSymbol(strPluginFileName); diff --git a/parameter/SystemClass.h b/parameter/SystemClass.h index 3ffbf25..b5bce45 100644 --- a/parameter/SystemClass.h +++ b/parameter/SystemClass.h @@ -111,6 +111,6 @@ private: // Subsystem factory CSubsystemLibrary* _pSubsystemLibrary; - std::list _subsystemLibraries; /**< Contains the list of all open plugin libs. */ + std::list _subsystemLibraryHandleList; /**< Contains the list of all open plugin libs. */ }; -- cgit v1.1