From: Philippe Waroquiers Date: Sun, 21 Oct 2012 21:03:11 +0000 (+0000) Subject: Fix 308711 - give more info about aspacemgr and arenas in out_of_memory X-Git-Tag: svn/VALGRIND_3_9_0~591 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c471293d4d6898cd96ab27472ecbdedbb7ee9d2;p=thirdparty%2Fvalgrind.git Fix 308711 - give more info about aspacemgr and arenas in out_of_memory 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 --- diff --git a/NEWS b/NEWS index 36121a2ddd..a99c178134 100644 --- 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 diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index b7f0a4a590..e64b75ba99 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -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);