libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [PATCH 24/35] Cleanup dynamically allocated memory bef


From: Tommi Rantala
Subject: [Libunwind-devel] [PATCH 24/35] Cleanup dynamically allocated memory before exit in tests
Date: Tue, 18 Sep 2012 16:31:33 +0300

Cleanup dynamically allocated memory before exit in tests in a few
places where missing. While such cleanups right before exit do not
usually make much sense (as the operating system would cleanup anyway,
so manual cleanups only burn CPU cycles), we will want to catch any
potential problems in libunwind related to the cleanups. This also stops
valgrind complaining about unreleased memory.
---
 tests/Gtest-bt.c             |    6 ++++++
 tests/Gtest-trace.c          |    6 ++++++
 tests/test-coredump-unwind.c |    1 +
 tests/test-proc-info.c       |    2 ++
 tests/test-ptrace.c          |    1 +
 5 files changed, 16 insertions(+)

diff --git a/tests/Gtest-bt.c b/tests/Gtest-bt.c
index fa28384..9c9bc5a 100644
--- a/tests/Gtest-bt.c
+++ b/tests/Gtest-bt.c
@@ -250,5 +250,11 @@ main (int argc, char **argv __attribute__((unused)))
     }
   if (verbose)
     printf ("SUCCESS.\n");
+
+  signal (SIGTERM, SIG_DFL);
+  stk.ss_flags = SS_DISABLE;
+  sigaltstack (&stk, NULL);
+  free (stk.ss_sp);
+
   return 0;
 }
diff --git a/tests/Gtest-trace.c b/tests/Gtest-trace.c
index 619026a..f626aa3 100644
--- a/tests/Gtest-trace.c
+++ b/tests/Gtest-trace.c
@@ -265,5 +265,11 @@ main (int argc, char **argv __attribute__((unused)))
 
   if (verbose)
     printf ("SUCCESS.\n");
+
+  signal (SIGTERM, SIG_DFL);
+  stk.ss_flags = SS_DISABLE;
+  sigaltstack (&stk, NULL);
+  free (stk.ss_sp);
+
   return 0;
 }
diff --git a/tests/test-coredump-unwind.c b/tests/test-coredump-unwind.c
index 13b45c3..6109bda 100644
--- a/tests/test-coredump-unwind.c
+++ b/tests/test-coredump-unwind.c
@@ -387,6 +387,7 @@ main(int argc __attribute__((unused)), char **argv)
     }
 
   _UCD_destroy(ui);
+  unw_destroy_addr_space(as);
 
   return 0;
 }
diff --git a/tests/test-proc-info.c b/tests/test-proc-info.c
index 3c8fdea..e97ef2b 100644
--- a/tests/test-proc-info.c
+++ b/tests/test-proc-info.c
@@ -162,6 +162,8 @@ main (int argc, char **argv)
     panic ("Second call to unw_step() returned %d instead of %d\n",
           ret, -UNW_ESTOPUNWIND);
 
+  unw_destroy_addr_space (as);
+
   if (verbose)
     printf ("SUCCESS\n");
   return 0;
diff --git a/tests/test-ptrace.c b/tests/test-ptrace.c
index 17a1b61..aecb06e 100644
--- a/tests/test-ptrace.c
+++ b/tests/test-ptrace.c
@@ -341,6 +341,7 @@ main (int argc, char **argv)
     }
 
   _UPT_destroy (ui);
+  unw_destroy_addr_space (as);
 
   if (nerrors)
     {
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]