From aaa145ea9b6892046299a9ddaa6286f0af3d3f32 Mon Sep 17 00:00:00 2001 From: Soren Sandmann Date: Fri, 2 Mar 2007 06:21:37 +0000 Subject: [PATCH] Make a copy of the vdso bytes to make valgrind a little quieter. 2007-03-02 Soren Sandmann * process.c (process_get_vdso_bytes): Make a copy of the vdso bytes to make valgrind a little quieter. * binparser.c: Note to self: Save the file, *then* commit. svn path=/trunk/; revision=357 --- ChangeLog | 7 +++++++ binparser.c | 2 ++ binparser.h | 3 +-- process.c | 13 ++++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83ecfc3f..e0145452 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-03-02 Soren Sandmann + + * process.c (process_get_vdso_bytes): Make a copy of the vdso + bytes to make valgrind a little quieter. + + * binparser.c: Note to self: Save the file, *then* commit. + 2007-03-02 Soren Sandmann Fix two leaks, both pointed out by Kjartan Maraas diff --git a/binparser.c b/binparser.c index 6b6c95a5..0a249814 100644 --- a/binparser.c +++ b/binparser.c @@ -75,6 +75,8 @@ bin_parser_free (BinParser *parser) g_free (record); } + + g_list_free (parser->records); g_free (parser); } diff --git a/binparser.h b/binparser.h index 4b0a853f..ebedf405 100644 --- a/binparser.h +++ b/binparser.h @@ -72,8 +72,7 @@ typedef enum struct BinField { const char name[BIN_MAX_NAME]; char type; - char n_bytes; /* number of bytes if type - * is UNINTERPRETED */ + char n_bytes; /* number of bytes in the type */ }; BinParser * bin_parser_new (const guchar *data, diff --git a/process.c b/process.c index 63832c9a..8ff8b7e4 100644 --- a/process.c +++ b/process.c @@ -175,8 +175,19 @@ process_get_vdso_bytes (gsize *length) if (strcmp (map->filename, "[vdso]") == 0) { - bytes = (guint8 *)map->start; n_bytes = map->end - map->start; + + /* Dup the memory here so that valgrind will only + * report one 1 byte invalid read instead of + * a ton when the elf parser scans the vdso + * + * The reason we get a spurious invalid read from + * valgrind is that we are getting the address directly + * from /proc/maps, and valgrind knows that its mmap() + * wrapper never returned that address. But since it + * is a legal mapping, it is legal to read it. + */ + bytes = g_memdup ((guint8 *)map->start, n_bytes); } }