]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix 308711 - give more info about aspacemgr and arenas in out_of_memory
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 21 Oct 2012 21:03:11 +0000 (21:03 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 21 Oct 2012 21:03:11 +0000 (21:03 +0000)
In case of out of memory, Valgrind will output
the state of the address space manager and of the arena.
Then it will output a message to inform the user about the out of memory.

In case out of memory happens again while outputting the aspacemgr
or arena info, then another trial is done to only output the user msg.

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

NEWS
coregrind/m_mallocfree.c

diff --git a/NEWS b/NEWS
index 36121a2ddd9095f1612a8f66b1fd53c8c26f9a68..a99c1781347849cc32e773323940b213064cdd48 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ m = merged into 3_8_BRANCH
 308321    [390] testsuite memcheck filter interferes with gdb_filter 
 308341    [390] vgdb should report process exit (or fatal signal)
 308644    [390] vgdb command for having the info for the track-fds option
+308711    [390] give more info about aspacemgr and arenas in out_of_memory
 n-i-bz    [390] report error for vgdb snapshot requested before execution
 n-i-bz    [390] Some wrong command line options could be ignored
 
index b7f0a4a59076c96a0e5f7474a28a42ae11e850d7..e64b75ba99e10e05f18099b66a5a37adc1ed40da 100644 (file)
@@ -704,7 +704,12 @@ void ensure_mm_init ( ArenaId aid )
 __attribute__((noreturn))
 void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB )
 {
-   static Bool alreadyCrashing = False;
+   static Int outputTrial = 0;
+   // We try once to output the full memory state followed by the below message.
+   // If that fails (due to out of memory during first trial), we try to just
+   // output the below message.
+   // And then we abandon.
+   
    ULong tot_alloc = VG_(am_get_anonsize_total)();
    Char* s1 = 
       "\n"
@@ -729,8 +734,15 @@ void VG_(out_of_memory_NORETURN) ( HChar* who, SizeT szB )
       "    3GB per process.\n\n"
       "    Whatever the reason, Valgrind cannot continue.  Sorry.\n";
 
-   if (!alreadyCrashing) {
-      alreadyCrashing = True;
+   if (outputTrial <= 1) {
+      if (outputTrial == 0) {
+         outputTrial++;
+         VG_(am_show_nsegments) (0, "out_of_memory");
+         VG_(print_all_arena_stats) ();
+         if (VG_(clo_profile_heap))
+            VG_(print_arena_cc_analysis) ();
+      }
+      outputTrial++;
       VG_(message)(Vg_UserMsg, s1, who, (ULong)szB, tot_alloc);
    } else {
       VG_(debugLog)(0,"mallocfree", s1, who, (ULong)szB, tot_alloc);