From: Nicholas Nethercote Date: Thu, 16 Apr 2009 00:37:57 +0000 (+0000) Subject: Merge r9556 (clarify crash/abort message) from the trunk. X-Git-Tag: svn/VALGRIND_3_4_1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5fa1c2d79eeefdf343654a45093303b1f572378;p=thirdparty%2Fvalgrind.git Merge r9556 (clarify crash/abort message) from the trunk. git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_4_BRANCH@9558 --- diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c index 7669be90de..43bda1cc1d 100644 --- a/coregrind/m_libcassert.c +++ b/coregrind/m_libcassert.c @@ -152,14 +152,19 @@ static void report_and_quit ( const Char* report, VG_(pp_StackTrace) (ips, BACKTRACE_DEPTH); VG_(show_sched_status)(); - VG_(printf)("\n"); - VG_(printf)("Note: see also the FAQ.txt in the source distribution.\n"); - VG_(printf)("It contains workarounds to several common problems.\n"); - VG_(printf)("\n"); - VG_(printf)("If that doesn't help, please report this bug to: %s\n\n", - report); - VG_(printf)("In the bug report, send all the above text, the valgrind\n"); - VG_(printf)("version, and what Linux distro you are using. Thanks.\n\n"); + VG_(printf)( + "\n" + "Note: see also the FAQ in the source distribution.\n" + "It contains workarounds to several common problems.\n" + "In particular, if Valgrind aborted or crashed after\n" + "identifying problems in your program, there's a good chance\n" + "that fixing those problems will prevent Valgrind aborting or\n" + "crashing, especially if it happened in m_mallocfree.c.\n" + "\n" + "If that doesn't help, please report this bug to: %s\n\n" + "In the bug report, send all the above text, the valgrind\n" + "version, and what OS and version you are using. Thanks.\n\n", + report); VG_(exit)(1); } diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index cdf13cfcc2..cf3176726d 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -200,23 +200,29 @@ typedef #define SIZE_T_0x1 ((SizeT)0x1) +static char* probably_your_fault = + "This is probably caused by your program erroneously writing past the\n" + "end of a heap block and corrupting heap metadata. If you fix any\n" + "invalid writes reported by Memcheck, this assertion failure will\n" + "probably go away. Please try that before reporting this as a bug.\n"; + // Mark a bszB as in-use, and not in-use, and remove the in-use attribute. static __inline__ SizeT mk_inuse_bszB ( SizeT bszB ) { - vg_assert(bszB != 0); + vg_assert2(bszB != 0, probably_your_fault); return bszB & (~SIZE_T_0x1); } static __inline__ SizeT mk_free_bszB ( SizeT bszB ) { - vg_assert(bszB != 0); + vg_assert2(bszB != 0, probably_your_fault); return bszB | SIZE_T_0x1; } static __inline__ SizeT mk_plain_bszB ( SizeT bszB ) { - vg_assert(bszB != 0); + vg_assert2(bszB != 0, probably_your_fault); return bszB & (~SIZE_T_0x1); } @@ -238,9 +244,8 @@ SizeT get_bszB_as_is ( Block* b ) SizeT bszB_lo = *(SizeT*)&b2[0 + hp_overhead_szB()]; SizeT bszB_hi = *(SizeT*)&b2[mk_plain_bszB(bszB_lo) - sizeof(SizeT)]; vg_assert2(bszB_lo == bszB_hi, - "Heap block lo/hi size mismatch: lo = %llu, hi = %llu.\n" - "Probably caused by overrunning/underrunning a heap block's bounds.\n", - (ULong)bszB_lo, (ULong)bszB_hi); + "Heap block lo/hi size mismatch: lo = %llu, hi = %llu.\n%s", + (ULong)bszB_lo, (ULong)bszB_hi, probably_your_fault); return bszB_lo; } @@ -267,7 +272,7 @@ static __inline__ Bool is_inuse_block ( Block* b ) { SizeT bszB = get_bszB_as_is(b); - vg_assert(bszB != 0); + vg_assert2(bszB != 0, probably_your_fault); return (0 != (bszB & SIZE_T_0x1)) ? False : True; } @@ -312,7 +317,7 @@ SizeT pszB_to_bszB ( Arena* a, SizeT pszB ) static __inline__ SizeT bszB_to_pszB ( Arena* a, SizeT bszB ) { - vg_assert(bszB >= overhead_szB(a)); + vg_assert2(bszB >= overhead_szB(a), probably_your_fault); return bszB - overhead_szB(a); } diff --git a/docs/xml/FAQ.xml b/docs/xml/FAQ.xml index cc7607d097..5115265a4c 100644 --- a/docs/xml/FAQ.xml +++ b/docs/xml/FAQ.xml @@ -142,7 +142,11 @@ collect2: ld returned 1 exit status My (buggy) program dies like this: -valgrind: m_mallocfree.c:442 (bszW_to_pszW): Assertion 'pszW >= 0' failed. +valgrind: m_mallocfree.c:248 (get_bszB_as_is): Assertion 'bszB_lo == bszB_hi' failed. + or like this: +valgrind: m_mallocfree.c:442 (mk_inuse_bszB): Assertion 'bszB != 0' failed. + or otherwise aborts or crashes in m_mallocfree.c. + If Memcheck (the memory checker) shows any invalid reads, @@ -162,16 +166,20 @@ collect2: ld returned 1 exit status vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x2E 0x5 - Older versions did not support some x86 and amd64 instructions, - particularly SSE/SSE2/SSE3 instructions. Try a newer Valgrind; we now - support almost all instructions. If it still breaks, file a bug + One possibility is that your program has a bug and erroneously + jumps to a non-code address, in which case you'll get a SIGILL signal. + Memcheck may issue a warning just before this happens, but it might not + if the jump happens to land in addressable memory. + + Another possibility is that Valgrind does not handle the + instruction. If you are using an older Valgrind, a newer version might + handle the instruction. However, all instruction sets have some + obscure, rarely used instructions. Also, on amd64 there are an almost + limitless number of combinations of redundant instruction prefixes, many + of them undocumented but accepted by CPUs. So Valgrind will still have + decoding failures from time to time. If this happens, please file a bug report. - Another possibility is that your program has a bug and - erroneously jumps to a non-code address, in which case you'll get a - SIGILL signal. Memcheck may issue a warning just before - this happens, but it might not if the jump happens to land in - addressable memory.