|
From: <sv...@va...> - 2009-03-10 23:16:17
|
Author: njn
Date: 2009-03-10 23:16:14 +0000 (Tue, 10 Mar 2009)
New Revision: 9352
Log:
Merge r9351 (make leak-cases tests more robust) from the trunk. These tests
now pass on Darwin.
Modified:
branches/DARWIN/memcheck/tests/leak-cases-full.stderr.exp
branches/DARWIN/memcheck/tests/leak-cases.c
Modified: branches/DARWIN/memcheck/tests/leak-cases-full.stderr.exp
===================================================================
--- branches/DARWIN/memcheck/tests/leak-cases-full.stderr.exp 2009-03-10 23:08:02 UTC (rev 9351)
+++ branches/DARWIN/memcheck/tests/leak-cases-full.stderr.exp 2009-03-10 23:16:14 UTC (rev 9352)
@@ -6,52 +6,61 @@
16 bytes in 1 blocks are possibly lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:91)
+ by 0x........: f (leak-cases.c:87)
+ by 0x........: main (leak-cases.c:107)
16 bytes in 1 blocks are possibly lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:91)
+ by 0x........: f (leak-cases.c:87)
+ by 0x........: main (leak-cases.c:107)
16 bytes in 1 blocks are possibly lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:88)
+ by 0x........: f (leak-cases.c:84)
+ by 0x........: main (leak-cases.c:107)
16 bytes in 1 blocks are possibly lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:88)
+ by 0x........: f (leak-cases.c:84)
+ by 0x........: main (leak-cases.c:107)
16 bytes in 1 blocks are possibly lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:85)
+ by 0x........: f (leak-cases.c:81)
+ by 0x........: main (leak-cases.c:107)
16 bytes in 1 blocks are possibly lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:82)
+ by 0x........: f (leak-cases.c:78)
+ by 0x........: main (leak-cases.c:107)
16 bytes in 1 blocks are definitely lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:78)
+ by 0x........: f (leak-cases.c:74)
+ by 0x........: main (leak-cases.c:107)
32 (16 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:80)
+ by 0x........: f (leak-cases.c:76)
+ by 0x........: main (leak-cases.c:107)
32 (16 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record ... of ...
at 0x........: malloc (vg_replace_malloc.c:...)
by 0x........: mk (leak-cases.c:52)
- by 0x........: main (leak-cases.c:95)
+ by 0x........: f (leak-cases.c:91)
+ by 0x........: main (leak-cases.c:107)
Modified: branches/DARWIN/memcheck/tests/leak-cases.c
===================================================================
--- branches/DARWIN/memcheck/tests/leak-cases.c 2009-03-10 23:08:02 UTC (rev 9351)
+++ branches/DARWIN/memcheck/tests/leak-cases.c 2009-03-10 23:16:14 UTC (rev 9352)
@@ -65,12 +65,8 @@
Node* p8;
Node* p9;
-int main(void)
+void f(void)
{
- DECLARE_LEAK_COUNTERS;
-
- GET_INITIAL_LEAK_COUNTS;
-
p1 = mk(NULL); // Case 1: 16/1 still reachable
p2 = mk(mk(NULL)); // Case 2: 16/1 still reachable
@@ -95,7 +91,21 @@
p9 = mk(mk(NULL)); // Case 9: 16/1 indirectly lost (counted again below!)
(p9->next)++; // 32(16d,16i)/1 definitely lost (double count!)
p9 = NULL;
+}
+int main(void)
+{
+ DECLARE_LEAK_COUNTERS;
+
+ GET_INITIAL_LEAK_COUNTS;
+
+ // Originally, this program did all the work in main(), but on some
+ // platforms (x86/Darwin and AMD64/Linux with --enable-only32bit) stray
+ // pointers to supposedly-lost heap blocks were being left on the stack,
+ // thus making them reachable. Doing the allocations in f() and the leak
+ // counting in main() avoids the problem.
+ f();
+
GET_FINAL_LEAK_COUNTS;
PRINT_LEAK_COUNTS(stderr);
|