]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Stop massif segfaulting due to stack overflow, when printing snapshots
authorJulian Seward <jseward@acm.org>
Tue, 13 May 2008 10:57:29 +0000 (10:57 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 13 May 2008 10:57:29 +0000 (10:57 +0000)
arising from large C++ applications on amd64-linux.

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

massif/ms_main.c

index 8d62e827715babc555effe003ac3d4a00c5e7f24..1f9d14c369fa805de8f20a203776b08038c49d3a 100644 (file)
@@ -1912,11 +1912,15 @@ static void pp_snapshot_SXPt(Int fd, SXPt* sxpt, Int depth, Char* depth_str,
 {
    Int   i, n_insig_children_sxpts;
    Char* perc;
-   Char  ip_desc_array[BUF_LEN];
-   Char* ip_desc = ip_desc_array;
    SXPt* pred  = NULL;
    SXPt* child = NULL;
 
+   // Used for printing function names.  Is made static to keep it out
+   // of the stack frame -- this function is recursive.  Obviously this
+   // now means its contents are trashed across the recursive call.
+   static Char ip_desc_array[BUF_LEN];
+   Char* ip_desc = ip_desc_array;
+
    switch (sxpt->tag) {
     case SigSXPt:
       // Print the SXPt itself.
@@ -1971,7 +1975,9 @@ static void pp_snapshot_SXPt(Int fd, SXPt* sxpt, Int depth, Char* depth_str,
          if (InsigSXPt == child->tag)
             n_insig_children_sxpts++;
 
-         // Ok, print the child.
+         // Ok, print the child.  NB: contents of ip_desc_array will be
+         // trashed by this recursive call.  Doesn't matter currently,
+         // but worth noting.
          pp_snapshot_SXPt(fd, child, depth+1, depth_str, depth_str_len,
             snapshot_heap_szB, snapshot_total_szB);
       }