- leak detective is usable, but does not show static function names
authorMartin Willi <martin@strongswan.org>
Thu, 13 Apr 2006 13:24:45 +0000 (13:24 -0000)
committerMartin Willi <martin@strongswan.org>
Thu, 13 Apr 2006 13:24:45 +0000 (13:24 -0000)
  - a script which gets address via ldd and resolves address via addr2line would be nice
- fixed a leak in child_sa with new detective ;-)

Source/Makefile
Source/charon/config/child_proposal.o [deleted file]
Source/charon/daemon.c
Source/charon/sa/child_sa.c
Source/lib/utils/logger_manager.c
Source/lib/utils/logger_manager.h
Source/testing/leak_detective_test.c

index 27a0ea3..40308ca 100644 (file)
@@ -23,13 +23,13 @@ BUILD_DIR= ./bin/
 BINNAMECHARON= $(BUILD_DIR)charon
 BINNAMESTROKE= $(BUILD_DIR)stroke
 BINNAMETEST= $(BUILD_DIR)run_tests
-BINNAMELIB=  $(BUILD_DIR)libstrong.so
+BINNAMELIB=  $(BUILD_DIR)libstrongswan.so
 
 MAIN_DIR= ./
 
 LDFLAGS= -ldl -lgmp -lpthread -rdynamic
 
-CFLAGS= -Icharon -Ilib -Istroke -Wall -g -fPIC #-DLEAK_DETECTIVE 
+CFLAGS= -Icharon -Ilib -Istroke -Wall -g -fPIC -DLEAK_DETECTIVE
 
 # objects is extended by each included Makefile
 CHARON_OBJS=
@@ -61,10 +61,10 @@ $(BINNAMELIB) :                             build_dir $(LIB_OBJS)
                                                        $(CC) -shared $(LIB_OBJS) -o $@
 
 $(BINNAMECHARON) :                     build_dir $(CHARON_OBJS) $(BINNAMELIB) $(BUILD_DIR)daemon.o
-                                                       $(CC) -ldl -lgmp -rdynamic -L./bin -lstrong -lpthread $(CHARON_OBJS) $(BUILD_DIR)daemon.o -o $@
+                                                       $(CC) -ldl -lgmp -rdynamic -L./bin -lstrongswan -lpthread $(CHARON_OBJS) $(BUILD_DIR)daemon.o -o $@
 
 $(BINNAMETEST) :                       build_dir $(CHARON_OBJS) $(TEST_OBJS) $(BINNAMELIB) $(BUILD_DIR)testcases.o
-                                                       $(CC) -L./bin -lstrong  $(LDFLAGS) $(CHARON_OBJS) $(TEST_OBJS) $(BUILD_DIR)testcases.o -o $@
+                                                       $(CC) -L./bin -lstrongswan  $(LDFLAGS) $(CHARON_OBJS) $(TEST_OBJS) $(BUILD_DIR)testcases.o -o $@
 
 $(BINNAMESTROKE) :                     build_dir $(BINNAMELIB) $(BUILD_DIR)stroke.o
                                                        $(CC) $(LDFLAGS) $(CFLAGS) $(BUILD_DIR)stroke.o -o $@
diff --git a/Source/charon/config/child_proposal.o b/Source/charon/config/child_proposal.o
deleted file mode 100644 (file)
index 8399232..0000000
Binary files a/Source/charon/config/child_proposal.o and /dev/null differ
index 6361f30..aafc86a 100644 (file)
@@ -263,12 +263,11 @@ void signal_handler(int signal)
 
        for (i = 0; i < size; i++)
        {
-               logger->log(logger, ERROR, "\t%s", strings[i]);
+               logger->log(logger, ERROR, "    %s", strings[i]);
        }
-
        free (strings);
-       
-       charon->kill(charon, "SIGSEGV received");
+       /* kill ourselve the hard way, anything other may result in more SIGSEGVs*/
+       kill(getpid(), SIGKILL);
 }
 
 /**
index fd82f12..28e9cdd 100644 (file)
@@ -447,6 +447,8 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list
                        {
                                my_iter->destroy(my_iter);
                                other_iter->destroy(other_iter);
+                               policy->my_net->destroy(policy->my_net);
+                               policy->other_net->destroy(policy->other_net);
                                free(policy);
                                return status;
                        }
index ab21676..de92d0a 100644 (file)
@@ -51,6 +51,8 @@ mapping_t logger_context_t_mappings[] = {
        {DER_DECODER, "DER_DECODER"},
        {DER_ENCODER, "DER_ENCODER"},
        {ASN1, "ASN1"},
+       {XFRM, "XFRM"},
+       {LEAK_DETECT, "LEAK_DETECT"},
        {MAPPING_END, NULL},
 };
 
@@ -80,6 +82,7 @@ struct {
        { "DEREC", ERROR|CONTROL|AUDIT|LEVEL0,  TRUE }, /* DER_ENCODER */
        { "ASN_1", ERROR|CONTROL|AUDIT|LEVEL0,  TRUE }, /* ASN1 */
        { "XFRM ", ERROR|CONTROL|AUDIT|LEVEL0,  TRUE }, /* XFRM */
+       { "LEAKD", ERROR|CONTROL|AUDIT|LEVEL0,  FALSE}, /* LEAK_DETECT */
 };
 
 
index 0815491..24806b8 100644 (file)
@@ -59,6 +59,7 @@ enum logger_context_t {
        DER_ENCODER,
        ASN1,
        XFRM,
+       LEAK_DETECT,
        LOGGER_CONTEXT_ROOF,
 };
 
index 193b818..8d71d9f 100644 (file)
 #include "leak_detective_test.h"
 
 
+void *mem_a, *mem_b, *mem_c;
+
 void a()
 {
-       malloc(4);
+       mem_a = malloc(4);
 }
 
 void b()
 {
        a();
-       malloc(5);
+       mem_b = malloc(5);
 }
 
 void c()
 {
        b();
-       malloc(6);
+       mem_c = malloc(6);
+}
+
+void recursive(int depth)
+{
+       void *tiny = malloc(1);
+       if (--depth > 0)
+       {
+               recursive(depth);
+       }
+       free(tiny);
 }
 
 
@@ -59,5 +71,9 @@ void test_leak_detective(protected_tester_t *tester)
        free(m3);
        free(m1);
        
-       //c();
+       c();
+       free(mem_a);
+       free(mem_c);
+       free(mem_b);
+       recursive(10000);
 }