[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
memchr and valgrind
From: |
Eric Blake |
Subject: |
memchr and valgrind |
Date: |
Mon, 15 Jun 2009 17:42:44 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
With the recent clarification on memchr behavior, it is conceivable that we
could trip false positives under valgrind when using memchr to find the
location of a known byte with an overestimated length (most frequently when
searching for a NUL). Any objections to applying this patch?
From: Eric Blake <address@hidden>
Date: Mon, 15 Jun 2009 11:04:21 -0600
Subject: [PATCH] memchr: add valgrind exception
* lib/memchr.valgrind: New file.
* modules/memchr (Files): Distribute it.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 4 ++++
lib/memchr.valgrind | 14 ++++++++++++++
modules/memchr | 1 +
3 files changed, 19 insertions(+), 0 deletions(-)
create mode 100644 lib/memchr.valgrind
diff --git a/ChangeLog b/ChangeLog
index 81af4ec..b2492be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2009-06-15 Eric Blake <address@hidden>
+ memchr: add valgrind exception
+ * lib/memchr.valgrind: New file.
+ * modules/memchr (Files): Distribute it.
+
docs: memchr is no longer obsolete
* MODULES.html.sh: Move memchr from obsolete to string.h section.
diff --git a/lib/memchr.valgrind b/lib/memchr.valgrind
new file mode 100644
index 0000000..60f247e
--- /dev/null
+++ b/lib/memchr.valgrind
@@ -0,0 +1,14 @@
+# Suppress a valgrind message about use of uninitialized memory in memchr().
+# POSIX states that when the character is found, memchr must not read extra
+# bytes in an overestimated length (for example, where memchr is used to
+# implement strnlen). However, we use a safe word read to provide a speedup.
+{
+ memchr-value4
+ Memcheck:Value4
+ fun:rpl_memchr
+}
+{
+ memchr-value8
+ Memcheck:Value8
+ fun:rpl_memchr
+}
diff --git a/modules/memchr b/modules/memchr
index a77bec5..855c8db 100644
--- a/modules/memchr
+++ b/modules/memchr
@@ -3,6 +3,7 @@ memchr() function: scan memory for a byte.
Files:
lib/memchr.c
+lib/memchr.valgrind
m4/memchr.m4
m4/mmap-anon.m4
--
1.6.3.1
- memchr and valgrind,
Eric Blake <=