Author: philippe
Date: Sun Oct 16 18:20:53 2016
New Revision: 16044
Log:
Further fixes following fix of leak in 16033
Rerunning valgrind under valgrind shows that interp_name and interp_args
memory was freed twice.
=> reworked the way interp_name and interp_args are freed:
* free them in VG_(ii_create_image) (linux/darwin/solaris)
* everywhere else, when overriden, first free the current value
* everywhere where interp_name or interp_args are freed, set them to NULL
With this, re-selfhosting valgrind shows no leak and no corruption
for interp_name and interp_args.
Modified:
trunk/coregrind/m_initimg/initimg-darwin.c
trunk/coregrind/m_initimg/initimg-linux.c
trunk/coregrind/m_initimg/initimg-solaris.c
trunk/coregrind/m_mallocfree.c
trunk/coregrind/m_ume/main.c
trunk/coregrind/m_ume/script.c
Modified: trunk/coregrind/m_initimg/initimg-darwin.c
==============================================================================
--- trunk/coregrind/m_initimg/initimg-darwin.c (original)
+++ trunk/coregrind/m_initimg/initimg-darwin.c Sun Oct 16 18:20:53 2016
@@ -428,14 +428,10 @@
*ptr++ = (Addr)(argc + 1);
/* --- client argv --- */
- if (info->interp_name) {
+ if (info->interp_name)
*ptr++ = (Addr)copy_str(&strtab, info->interp_name);
- VG_(free)(info->interp_name);
- }
- if (info->interp_args) {
+ if (info->interp_args)
*ptr++ = (Addr)copy_str(&strtab, info->interp_args);
- VG_(free)(info->interp_args);
- }
*ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
@@ -566,8 +562,8 @@
// Tell aspacem about commpage, etc
record_system_memory();
- VG_(free)(info.interp_name);
- VG_(free)(info.interp_args);
+ VG_(free)(info.interp_name); info.interp_name = NULL;
+ VG_(free)(info.interp_args); info.interp_args = NULL;
return iifii;
}
Modified: trunk/coregrind/m_initimg/initimg-linux.c
==============================================================================
--- trunk/coregrind/m_initimg/initimg-linux.c (original)
+++ trunk/coregrind/m_initimg/initimg-linux.c Sun Oct 16 18:20:53 2016
@@ -584,14 +584,10 @@
*ptr++ = argc + 1;
/* --- client argv --- */
- if (info->interp_name) {
+ if (info->interp_name)
*ptr++ = (Addr)copy_str(&strtab, info->interp_name);
- VG_(free)(info->interp_name);
- }
- if (info->interp_args) {
+ if (info->interp_args)
*ptr++ = (Addr)copy_str(&strtab, info->interp_args);
- VG_(free)(info->interp_args);
- }
*ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
@@ -1017,8 +1013,8 @@
setup_client_dataseg( dseg_max_size );
}
- VG_(free)(info.interp_name);
- VG_(free)(info.interp_args);
+ VG_(free)(info.interp_name); info.interp_name = NULL;
+ VG_(free)(info.interp_args); info.interp_args = NULL;
return iifii;
}
Modified: trunk/coregrind/m_initimg/initimg-solaris.c
==============================================================================
--- trunk/coregrind/m_initimg/initimg-solaris.c (original)
+++ trunk/coregrind/m_initimg/initimg-solaris.c Sun Oct 16 18:20:53 2016
@@ -581,14 +581,10 @@
*ptr++ = argc;
/* Copy-out client argv. */
- if (info->interp_name) {
+ if (info->interp_name)
*ptr++ = (Addr)copy_str(&strtab, info->interp_name);
- VG_(free)(info->interp_name);
- }
- if (info->interp_args) {
+ if (info->interp_args)
*ptr++ = (Addr)copy_str(&strtab, info->interp_args);
- VG_(free)(info->interp_args);
- }
*ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
for (i = 0; i < VG_(sizeXA)(VG_(args_for_client)); i++)
@@ -959,8 +955,8 @@
}
}
- VG_(free)(info.interp_name);
- VG_(free)(info.interp_args);
+ VG_(free)(info.interp_name); VG_(free)(info->interp_name);
+ VG_(free)(info.interp_args); VG_(free)(info->interp_args);
return iifii;
}
Modified: trunk/coregrind/m_mallocfree.c
==============================================================================
--- trunk/coregrind/m_mallocfree.c (original)
+++ trunk/coregrind/m_mallocfree.c Sun Oct 16 18:20:53 2016
@@ -2098,7 +2098,7 @@
/* If this is one of V's areas, check carefully the block we're
getting back. This picks up simple block-end overruns. */
if (aid != VG_AR_CLIENT)
- vg_assert(blockSane(a, b));
+ vg_assert(is_inuse_block(b) && blockSane(a, b));
b_bszB = get_bszB(b);
b_pszB = bszB_to_pszB(a, b_bszB);
Modified: trunk/coregrind/m_ume/main.c
==============================================================================
--- trunk/coregrind/m_ume/main.c (original)
+++ trunk/coregrind/m_ume/main.c Sun Oct 16 18:20:53 2016
@@ -223,9 +223,9 @@
// Looks like a script. Run it with /bin/sh. This includes
// zero-length files.
-
+ VG_(free)(info->interp_name);
info->interp_name = VG_(strdup)("ume.desf.1", default_interp_name);
- info->interp_args = NULL;
+ VG_(free)(info->interp_args); info->interp_args = NULL;
if (info->argv && info->argv[0] != NULL)
info->argv[0] = exe_name;
@@ -281,9 +281,9 @@
Int VG_(do_exec)(const HChar* exe_name, ExeInfo* info)
{
Int ret;
-
- info->interp_name = NULL;
- info->interp_args = NULL;
+
+ VG_(free)(info->interp_name); info->interp_name = NULL;
+ VG_(free)(info->interp_args); info->interp_args = NULL;
ret = VG_(do_exec_inner)(exe_name, info);
Modified: trunk/coregrind/m_ume/script.c
==============================================================================
--- trunk/coregrind/m_ume/script.c (original)
+++ trunk/coregrind/m_ume/script.c Sun Oct 16 18:20:53 2016
@@ -115,7 +115,7 @@
cp++;
*cp = '\0';
}
-
+ VG_(free)(info->interp_name);
info->interp_name = VG_(strdup)("ume.ls.1", interp);
vg_assert(NULL != info->interp_name);
if (arg != NULL && *arg != '\0') {
|