diff options
author | Timo Lotterbach <timo.lotterbach@bmw-carit.de> | 2013-07-03 16:11:06 +0200 |
---|---|---|
committer | Timo Lotterbach <timo.lotterbach@bmw-carit.de> | 2013-07-05 12:56:48 +0200 |
commit | 6a580ea1b6137b7c229f04bc267eea9b5ee572f1 (patch) | |
tree | 8dcd5f5ddcb384388589a988a2fd3ee314b280ad | |
parent | 9d3e1d1509a1c42afa648d5a2653435bbc578138 (diff) | |
download | layer_management-6a580ea1b6137b7c229f04bc267eea9b5ee572f1.tar.gz |
LayerManagement: fixed issues detected by valgrind
Signed-off-by: Timo Lotterbach <timo.lotterbach@bmw-carit.de>
8 files changed, 135 insertions, 12 deletions
diff --git a/LayerManagerBase/src/Layermanager.cpp b/LayerManagerBase/src/Layermanager.cpp index 9ce777b..caee5e0 100644 --- a/LayerManagerBase/src/Layermanager.cpp +++ b/LayerManagerBase/src/Layermanager.cpp @@ -79,19 +79,58 @@ Layermanager::~Layermanager() delete m_pHealthMonitorList; } + if (m_pScene) + { + delete m_pScene; + } + + if (m_pRendererList) + { + RendererListIterator iter = m_pRendererList->begin(); + RendererListIterator iterEnd = m_pRendererList->end(); + for (; iter != iterEnd; ++iter) + { + delete *iter; + } + delete m_pRendererList; + } + + if (m_pCommunicatorList) + { + CommunicatorListIterator iter = m_pCommunicatorList->begin(); + CommunicatorListIterator iterEnd = m_pCommunicatorList->end(); + for (; iter != iterEnd; ++iter) + { + delete *iter; + } + delete m_pCommunicatorList; + } + if (m_pApplicationReferenceMap) { + ApplicationReferenceMap::iterator iter = m_pApplicationReferenceMap->begin(); + ApplicationReferenceMap::iterator end = m_pApplicationReferenceMap->end(); + for (; iter != end; ++iter) + { + delete iter->second; + } delete m_pApplicationReferenceMap; } - if (m_pPluginManager) + if (m_pSceneProviderList) { - delete m_pPluginManager; + SceneProviderListIterator iter = m_pSceneProviderList->begin(); + SceneProviderListIterator iterEnd = m_pSceneProviderList->end(); + for (; iter != iterEnd; ++iter) + { + delete *iter; + } + delete m_pSceneProviderList; } - if (m_pScene) + if (m_pPluginManager) { - delete m_pScene; + delete m_pPluginManager; } } @@ -186,6 +225,7 @@ void Layermanager::removeApplicationReference(t_ilm_client_handle client) { unsigned int pid = getSenderPid(client); LOG_INFO("LayerManagerService", "Disconnect from application " << getSenderName(client) << "(" << pid << ")"); + delete (*m_pApplicationReferenceMap)[client]; m_pApplicationReferenceMap->erase(client); m_pidToProcessNameTable.erase(pid); @@ -195,6 +235,15 @@ void Layermanager::removeApplicationReference(t_ilm_client_handle client) // commands of currently running applications if (0 != pid) { + CommandList& commandList = m_EnqueuedCommands[pid]; + CommandList::iterator iter = commandList.begin(); + CommandList::iterator end = commandList.end(); + for (; iter != end; ++iter) + { + delete *iter; + } + + m_EnqueuedCommands[pid].clear(); m_EnqueuedCommands.erase(pid); } } diff --git a/LayerManagerBase/src/Scene.cpp b/LayerManagerBase/src/Scene.cpp index 1f35fca..ae413e7 100644 --- a/LayerManagerBase/src/Scene.cpp +++ b/LayerManagerBase/src/Scene.cpp @@ -34,6 +34,31 @@ Scene::Scene() Scene::~Scene() { + { + ShaderMap::iterator iter = m_shaderMap.begin(); + ShaderMap::iterator end = m_shaderMap.end(); + for (; iter != end; ++iter) + { + delete iter->second; + } + } + { + SurfaceMap::iterator iter = m_surfaceMap.begin(); + SurfaceMap::iterator end = m_surfaceMap.end(); + for (; iter != end; ++iter) + { + delete iter->second; + } + } + { + LayerMap::iterator iter = m_layerMap.begin(); + LayerMap::iterator end = m_layerMap.end(); + for (; iter != end; ++iter) + { + delete iter->second; + } + } + pthread_mutex_destroy(&m_layerListMutex); } diff --git a/LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp b/LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp index 17a4a04..c30cd5c 100644 --- a/LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp +++ b/LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp @@ -116,6 +116,7 @@ bool ExampleSceneProvider::delegateScene() } /* Finally set the first executed renderorder */ } + delete [] screenResolution; return result; } diff --git a/LayerManagerPlugins/Communicators/GenericCommunicator/src/GenericCommunicator.cpp b/LayerManagerPlugins/Communicators/GenericCommunicator/src/GenericCommunicator.cpp index 0984477..8386cd1 100644 --- a/LayerManagerPlugins/Communicators/GenericCommunicator/src/GenericCommunicator.cpp +++ b/LayerManagerPlugins/Communicators/GenericCommunicator/src/GenericCommunicator.cpp @@ -294,6 +294,7 @@ void GenericCommunicator::process(int timeout_ms) Surface* surface = surfaceIter->second; surface->removeNotification(senderHandle); } + m_executor->removeApplicationReference(senderHandle); } break; @@ -405,6 +406,8 @@ void GenericCommunicator::GetScreenResolution(t_ilm_message message) m_ipcModule.appendUint(response, resolution[1]); m_ipcModule.sendToClients(response, &clientHandle, 1); m_ipcModule.destroyMessage(response); + + delete [] resolution; } void GenericCommunicator::GetNumberOfHardwareLayers(t_ilm_message message) @@ -430,6 +433,7 @@ void GenericCommunicator::GetScreenIDs(t_ilm_message message) m_ipcModule.appendUintArray(response, IDs, length); m_ipcModule.sendToClients(response, &clientHandle, 1); m_ipcModule.destroyMessage(response); + delete [] IDs; } void GenericCommunicator::ScreenShot(t_ilm_message message) @@ -547,6 +551,8 @@ void GenericCommunicator::ListAllLayerIDsOnScreen(t_ilm_message message) m_ipcModule.sendToClients(response, &clientHandle, 1); m_ipcModule.destroyMessage(response); + + delete [] array; } void GenericCommunicator::ListAllSurfaceIDS(t_ilm_message message) @@ -590,6 +596,7 @@ void GenericCommunicator::ListSurfaceofLayer(t_ilm_message message) response = m_ipcModule.createResponse(message); m_ipcModule.appendUintArray(response, array, length); + delete [] array; } else { @@ -960,6 +967,8 @@ void GenericCommunicator::CreateLayerFromId(t_ilm_message message) m_ipcModule.sendToClients(response, &clientHandle, 1); m_ipcModule.destroyMessage(response); + + delete [] resolution; } @@ -1665,7 +1674,7 @@ void GenericCommunicator::GetSurfacePixelformat(t_ilm_message message) t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message); t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle); uint id = 0; - PixelFormat pixelFormat; + PixelFormat pixelFormat = (PixelFormat)ILM_PIXEL_FORMAT_UNKNOWN; m_ipcModule.getUint(message, &id); @@ -1743,7 +1752,7 @@ void GenericCommunicator::GetSurfaceVisibility(t_ilm_message message) t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message); t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle); uint id = 0; - bool visibility; + bool visibility = false; m_ipcModule.getUint(message, &id); @@ -1769,7 +1778,7 @@ void GenericCommunicator::GetLayerVisibility(t_ilm_message message) t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message); t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle); uint id = 0; - bool visibility; + bool visibility = false; m_ipcModule.getUint(message, &id); @@ -1860,11 +1869,21 @@ void GenericCommunicator::SetRenderOrderOfLayers(t_ilm_message message) t_ilm_message response; t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message); t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle); + + // ipcArray was created in ipcModule using malloc (it's implemented C) + // so we copy it to a buffer created with new() and discard + // the ipcArray using free() to avoid memory corruption + uint* ipcArray = NULL; uint* array = NULL; int length = 0; + m_ipcModule.getUintArray(message, &ipcArray, &length); + array = new uint[length]; + memset(array, 0, length * sizeof(uint)); + memcpy(array, ipcArray, length * sizeof(uint)); + free(ipcArray); + uint screenID = 0; - m_ipcModule.getUintArray(message, &array, &length); m_ipcModule.getUint(message, &screenID); t_ilm_bool status = m_executor->execute(new ScreenSetRenderOrderCommand(clientPid, screenID, array, length)); @@ -1887,12 +1906,21 @@ void GenericCommunicator::SetSurfaceRenderOrderWithinLayer(t_ilm_message message t_ilm_message response; t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message); t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle); - uint* array = NULL; - int length = 0; - uint layerid = 0; + uint layerid = 0; m_ipcModule.getUint(message, &layerid); - m_ipcModule.getUintArray(message, &array, &length); + + // ipcArray was created in ipcModule using malloc (it's implemented C) + // so we copy it to a buffer created with new() and discard + // the ipcArray using free() to avoid memory corruption + uint* ipcArray = NULL; + uint* array = NULL; + int length = 0; + m_ipcModule.getUintArray(message, &ipcArray, &length); + array = new uint[length]; + memset(array, 0, length * sizeof(uint)); + memcpy(array, ipcArray, length * sizeof(uint)); + free(ipcArray); t_ilm_bool status = m_executor->execute(new LayerSetRenderOrderCommand(clientPid, layerid, array, length)); if (status) diff --git a/LayerManagerPlugins/Renderers/Graphic/include/GraphicSystems/BaseGraphicSystem.h b/LayerManagerPlugins/Renderers/Graphic/include/GraphicSystems/BaseGraphicSystem.h index 37b885b..47b04d6 100644 --- a/LayerManagerPlugins/Renderers/Graphic/include/GraphicSystems/BaseGraphicSystem.h +++ b/LayerManagerPlugins/Renderers/Graphic/include/GraphicSystems/BaseGraphicSystem.h @@ -35,6 +35,10 @@ public: virtual bool init(DisplayType display, WindowType window)=0; virtual ~BaseGraphicSystem() { + if (m_binder) + { + delete m_binder; + } }; virtual void beginLayer(Layer* layer) = 0; virtual void endLayer() = 0; diff --git a/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp b/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp index 451a6f1..9189cfa 100644 --- a/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp +++ b/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp @@ -93,6 +93,7 @@ X11WindowSystem::~X11WindowSystem() if (windowVis) { delete windowVis; + windowVis = NULL; } } @@ -1134,6 +1135,7 @@ void X11WindowSystem::cleanup() if (windowVis) { delete windowVis; + windowVis = NULL; } if (NULL != displaySignal) diff --git a/LayerManagerUtils/src/Log.cpp b/LayerManagerUtils/src/Log.cpp index 21d3036..09a764f 100644 --- a/LayerManagerUtils/src/Log.cpp +++ b/LayerManagerUtils/src/Log.cpp @@ -88,6 +88,8 @@ Log::~Log() { // TODO Auto-generated destructor stub m_fileStream->close(); + delete m_fileStream; + m_fileStream = NULL; pthread_mutex_destroy(&m_LogBufferMutex); Log::m_instance = NULL; #ifdef WITH_DLT @@ -95,6 +97,16 @@ Log::~Log() delete((DltContext*)m_logContext); DLT_UNREGISTER_APP(); #endif + Log::DiagnosticCallbackMap::iterator iter = m_diagnosticCallbackMap->begin(); + Log::DiagnosticCallbackMap::iterator iterEnd = m_diagnosticCallbackMap->end(); + for (; iter != iterEnd; ++iter) + { + diagnosticCallbackData* callback = iter->second; + if (callback) + { + delete callback; + } + } delete m_diagnosticCallbackMap; m_diagnosticCallbackMap = NULL; m_logContext = NULL; @@ -220,6 +232,7 @@ void Log::registerDiagnosticInjectionCallback(unsigned int module_id, diagnostic void Log::unregisterDiagnosticInjectionCallback(unsigned int module_id) { + delete (*m_diagnosticCallbackMap)[module_id]; m_diagnosticCallbackMap->erase(module_id); } diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index ff6d061..a8ae369 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -16,6 +16,7 @@ Improvements: - adding new interface ilm_setSynchronizedSurfaces, ilm_removeSynchronizedSurfaces to establish synchronized composition on dedicated surfaces this avoids e.g. flickering during night/day switch. +- X11EglImage: fixing a issue which causes memory leak in XServer Version 1.0 ------------------ |