]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Further fixes following fix of leak in 16033
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 16 Oct 2016 17:20:53 +0000 (17:20 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 16 Oct 2016 17:20:53 +0000 (17:20 +0000)
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.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16044

coregrind/m_initimg/initimg-darwin.c
coregrind/m_initimg/initimg-linux.c
coregrind/m_initimg/initimg-solaris.c
coregrind/m_mallocfree.c
coregrind/m_ume/main.c
coregrind/m_ume/script.c

index 5052e8670c0ab690c5e32b373ffa8af4bd8e15c5..9ff17457911e4306791b945f7f20219958ce4ab5 100644 (file)
@@ -428,14 +428,10 @@ Addr setup_client_stack( void*  init_sp,
    *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 @@ IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo iicii,
    // 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;
 }
 
index 299b73ddafc19d8cd6e431e8805176bc50e27d7c..2822f97a36da0ca084ec3b4fbec94243867527a4 100644 (file)
@@ -584,14 +584,10 @@ Addr setup_client_stack( void*  init_sp,
    *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 @@ IIFinaliseImageInfo VG_(ii_create_image)( IICreateImageInfo iicii,
       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;
 }
 
index c48ce14823c33f6a4b81aff53e2b2a20b59e04e9..537e527afc51869509a536abb63d810c797222db 100644 (file)
@@ -581,14 +581,10 @@ static Addr setup_client_stack(Addr init_sp,
    *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 @@ IIFinaliseImageInfo VG_(ii_create_image)(IICreateImageInfo iicii,
       }
    }
 
-   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;
 }
 
index f877d90524857ab2216f09df62911c9aaadcae2e..c047d8204513271743f2f29f73a025d69c15bcdd 100644 (file)
@@ -2098,7 +2098,7 @@ void VG_(arena_free) ( ArenaId aid, void* ptr )
    /* 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);
index a319f4acc47bf8075fec6efb84a45eee76c49aaa..3125a8e8d16b7431d76e5c53ba7a60abdaa3f2e3 100644 (file)
@@ -223,9 +223,9 @@ static Int do_exec_shell_followup(Int ret, const HChar* exe_name, ExeInfo* info)
 
       // 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 @@ static Int do_exec_shell_followup(Int ret, const HChar* exe_name, ExeInfo* info)
 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);
 
index 7f6b5b652ab3e8b2b41993e98c1549253748cb7a..3ebe6d9bf1bdbafe4475926ad69d386906dc2e11 100644 (file)
@@ -115,7 +115,7 @@ Int VG_(load_script)(Int fd, const HChar* name, ExeInfo* info)
          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') {