Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1B76D200BAC for ; Wed, 26 Oct 2016 14:15:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1A3A6160AEE; Wed, 26 Oct 2016 12:15:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3C928160AFD for ; Wed, 26 Oct 2016 14:15:26 +0200 (CEST) Received: (qmail 32665 invoked by uid 500); 26 Oct 2016 12:15:25 -0000 Mailing-List: contact commits-help@celix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@celix.apache.org Delivered-To: mailing list commits@celix.apache.org Received: (qmail 32425 invoked by uid 99); 26 Oct 2016 12:15:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Oct 2016 12:15:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E0E73F1596; Wed, 26 Oct 2016 12:15:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pnoltes@apache.org To: commits@celix.apache.org Date: Wed, 26 Oct 2016 12:15:30 -0000 Message-Id: <21fb006c90f74a5196bece6349c564cb@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/50] [abbrv] celix git commit: CELIX-374: Adapted defines and Cmake macros for RTLD_NODELETE debug-only builds. Fixed also couple of leaks found during testing. archived-at: Wed, 26 Oct 2016 12:15:27 -0000 CELIX-374: Adapted defines and Cmake macros for RTLD_NODELETE debug-only builds. Fixed also couple of leaks found during testing. Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/b92649ab Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/b92649ab Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/b92649ab Branch: refs/heads/master Commit: b92649ab54f158e98a57611949170bad95535d6c Parents: dacd179 Author: gricciardi Authored: Wed Sep 7 17:06:50 2016 +0200 Committer: gricciardi Committed: Wed Sep 7 17:06:50 2016 +0200 ---------------------------------------------------------------------- CMakeLists.txt | 2 ++ examples/mongoose/private/src/mongoose.c | 2 +- framework/private/src/framework.c | 17 ++++++++++++++--- framework/private/src/service_registry.c | 6 +++--- shell/private/src/inspect_command.c | 10 ++++++++++ 5 files changed, 30 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/b92649ab/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3088612..d1c5886 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,8 @@ ENDIF() IF(UNIX AND NOT ANDROID) SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall -Werror -fPIC ${CMAKE_C_FLAGS}") SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") #TODO enable -Wall -Werror -> warning in cpputest + SET(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") + SET(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG") ENDIF() IF(UNIX AND NOT APPLE) SET(CMAKE_C_FLAGS "-pthread ${CMAKE_C_FLAGS}") http://git-wip-us.apache.org/repos/asf/celix/blob/b92649ab/examples/mongoose/private/src/mongoose.c ---------------------------------------------------------------------- diff --git a/examples/mongoose/private/src/mongoose.c b/examples/mongoose/private/src/mongoose.c index 68f1a77..4397b94 100644 --- a/examples/mongoose/private/src/mongoose.c +++ b/examples/mongoose/private/src/mongoose.c @@ -1314,7 +1314,7 @@ int mg_read(struct mg_connection *conn, void *buf, size_t len) { const char *buffered; assert(conn->content_len >= conn->consumed_content); - DEBUG_TRACE(("%p %zu %lld %lld", buf, len, + DEBUG_TRACE(("%p %zu %ld %ld", buf, len, conn->content_len, conn->consumed_content)); nread = 0; if (strcmp(conn->request_info.request_method, "POST") == 0 && http://git-wip-us.apache.org/repos/asf/celix/blob/b92649ab/framework/private/src/framework.c ---------------------------------------------------------------------- diff --git a/framework/private/src/framework.c b/framework/private/src/framework.c index e6c736a..c6da0d5 100644 --- a/framework/private/src/framework.c +++ b/framework/private/src/framework.c @@ -160,6 +160,17 @@ static void framework_loggerInit(void) { logger->logFunction = frameworkLogger_log; } +/* Note: RTLD_NODELETE flag is needed in order to obtain a readable valgrind output. + * Valgrind output is written when the application terminates, so symbols resolving + * is impossible if dlopened libraries are unloaded before the application ends. + * RTLD_NODELETE closes the dynamic library but does not unload it from the memory space, + * so that symbols will be available until the application terminates. + * On the other hand, since the memory mapping is not destroyed after dlclose, calling again + * dlopen for the same library clashes with the previous mapping: this breaks the memory layout + * in case the user, for example, uninstall (dlclose) and install the bundle again (dlopen) + * So, RTLD_NODELETE should be used only for debugging purposes. + * Refer to dlopen manpage for additional details about libraries dynamic loading. + */ #ifdef _WIN32 #define handle_t HMODULE #define fw_openLibrary(path) LoadLibrary(path) @@ -176,10 +187,10 @@ static void framework_loggerInit(void) { } #else #define handle_t void * - #ifdef ANDROID - #define fw_openLibrary(path) dlopen(path, RTLD_LAZY|RTLD_LOCAL) + #if defined(DEBUG) && !defined(ANDROID) + #define fw_openLibrary(path) dlopen(path, RTLD_LAZY|RTLD_LOCAL|RTLD_NODELETE) #else - #define fw_openLibrary(path) dlopen(path, RTLD_LAZY|RTLD_LOCAL|RTLD_NODELETE) + #define fw_openLibrary(path) dlopen(path, RTLD_LAZY|RTLD_LOCAL) #endif #define fw_closeLibrary(handle) dlclose(handle) #define fw_getSymbol(handle, name) dlsym(handle, name) http://git-wip-us.apache.org/repos/asf/celix/blob/b92649ab/framework/private/src/service_registry.c ---------------------------------------------------------------------- diff --git a/framework/private/src/service_registry.c b/framework/private/src/service_registry.c index a5dd20c..49f0638 100644 --- a/framework/private/src/service_registry.c +++ b/framework/private/src/service_registry.c @@ -35,10 +35,10 @@ #include "service_reference_private.h" #include "framework_private.h" -#ifdef NDEBUG -#define CHECK_DELETED_REFERENCES false -#else +#ifdef DEBUG #define CHECK_DELETED_REFERENCES true +#else +#define CHECK_DELETED_REFERENCES false #endif static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt *registration); http://git-wip-us.apache.org/repos/asf/celix/blob/b92649ab/shell/private/src/inspect_command.c ---------------------------------------------------------------------- diff --git a/shell/private/src/inspect_command.c b/shell/private/src/inspect_command.c index f53a163..cb93e9c 100644 --- a/shell/private/src/inspect_command.c +++ b/shell/private/src/inspect_command.c @@ -149,6 +149,8 @@ celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, a fprintf(outStream, "%s = %s\n", key, value); } + free(keys); + // objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS); // sprintf(line, "ObjectClass = %s\n", objectClass); if ((j + 1) < arrayList_size(refs)) { @@ -159,6 +161,10 @@ celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, a } } } + + if(refs!=NULL){ + arrayList_destroy(refs); + } } } } @@ -256,6 +262,10 @@ celix_status_t inspectCommand_printImportedServices(bundle_context_pt context, a } } } + + if(refs!=NULL){ + arrayList_destroy(refs); + } } } }