|
From: <sv...@va...> - 2009-06-26 07:00:08
|
Author: njn
Date: 2009-06-26 08:00:00 +0100 (Fri, 26 Jun 2009)
New Revision: 10380
Log:
Suppress a leak in setenv(). Fixes bug 188572.
Added:
trunk/memcheck/tests/darwin/env.c
trunk/memcheck/tests/darwin/env.stderr.exp
trunk/memcheck/tests/darwin/env.vgtest
Modified:
trunk/darwin9.supp
trunk/memcheck/tests/darwin/Makefile.am
Modified: trunk/darwin9.supp
===================================================================
--- trunk/darwin9.supp 2009-06-26 04:35:51 UTC (rev 10379)
+++ trunk/darwin9.supp 2009-06-26 07:00:00 UTC (rev 10380)
@@ -143,7 +143,19 @@
fun:puts
}
+# Genuine leaks.
+# See https://bugs.kde.org/show_bug.cgi?id=188572 about this; it's
+# unavoidable due to BSD setenv() semantics.
+{
+ <insert a suppression name here>
+ Memcheck:Leak
+ fun:malloc_zone_malloc
+ fun:__setenv
+ fun:setenv$UNIX2003
+ fun:main
+}
+
##----------------------------------------------------------------------##
#
# Suppressions for Helgrind.
Modified: trunk/memcheck/tests/darwin/Makefile.am
===================================================================
--- trunk/memcheck/tests/darwin/Makefile.am 2009-06-26 04:35:51 UTC (rev 10379)
+++ trunk/memcheck/tests/darwin/Makefile.am 2009-06-26 07:00:00 UTC (rev 10380)
@@ -6,6 +6,7 @@
noinst_HEADERS = scalar.h
EXTRA_DIST = \
+ env.stderr.exp env.vgtest \
pth-supp.stderr.exp pth-supp.vgtest \
scalar.stderr.exp scalar.vgtest \
scalar_fork.stderr.exp scalar_fork.vgtest \
@@ -13,6 +14,7 @@
scalar_vfork.stderr.exp scalar_vfork.vgtest
check_PROGRAMS = \
+ env \
pth-supp \
scalar \
scalar_fork \
Added: trunk/memcheck/tests/darwin/env.c
===================================================================
--- trunk/memcheck/tests/darwin/env.c (rev 0)
+++ trunk/memcheck/tests/darwin/env.c 2009-06-26 07:00:00 UTC (rev 10380)
@@ -0,0 +1,31 @@
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+
+// This tests that the suppression for the leak in setenv() works. See bug
+// 188572.
+
+int main(void)
+{
+ char* val1 = "x";
+ char* val2 = "xx";
+ char* val3 = "xxx";
+
+ setenv("MYVAR", val1, /*overwrite*/0); // makes a copy which is later leaked
+ assert( 0 == strcmp(getenv("MYVAR"), val1) );
+
+ setenv("MYVAR", val2, /*overwrite*/1); // makes a copy which is later leaked
+ assert( 0 == strcmp(getenv("MYVAR"), val2) );
+
+ setenv("MYVAR", val3, /*overwrite*/0); // doesn't overwrite MYVAR=val2
+ assert( 0 == strcmp(getenv("MYVAR"), val2) );
+
+ putenv("MYVAR=xxxx"); // no leak for putenv()
+ assert( 0 == strcmp(getenv("MYVAR"), "xxxx") );
+
+ unsetenv("MYVAR");
+ assert( NULL == getenv("MYVAR") );
+
+ return 0;
+}
+
Added: trunk/memcheck/tests/darwin/env.stderr.exp
===================================================================
Added: trunk/memcheck/tests/darwin/env.vgtest
===================================================================
--- trunk/memcheck/tests/darwin/env.vgtest (rev 0)
+++ trunk/memcheck/tests/darwin/env.vgtest 2009-06-26 07:00:00 UTC (rev 10380)
@@ -0,0 +1,2 @@
+prog: env
+vgopts: -q --leak-check=full
|