From: Nicholas Nethercote Date: Wed, 6 May 2009 06:52:47 +0000 (+0000) Subject: Make loss record ordering more deterministic, so that regtests are reliable. X-Git-Tag: svn/VALGRIND_3_5_0~717 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f2db665454790edbe70605960a91d08fd15467d;p=thirdparty%2Fvalgrind.git Make loss record ordering more deterministic, so that regtests are reliable. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9784 --- diff --git a/memcheck/mc_leakcheck.c b/memcheck/mc_leakcheck.c index a3fdd8f7c9..1a402df680 100644 --- a/memcheck/mc_leakcheck.c +++ b/memcheck/mc_leakcheck.c @@ -782,6 +782,15 @@ static Int cmp_LossRecords(void* va, void* vb) // If size are equal, compare by states. if (lr_a->key.state < lr_b->key.state) return -1; if (lr_a->key.state > lr_b->key.state) return 1; + // If they're still equal here, it doesn't matter that much, but we keep + // comparing other things so that regtests are as deterministic as + // possible. So: compare num_blocks. + if (lr_a->num_blocks < lr_b->num_blocks) return -1; + if (lr_a->num_blocks > lr_b->num_blocks) return 1; + // Finally, compare ExeContext addresses... older ones are likely to have + // lower addresses. + if (lr_a->key.allocated_at < lr_b->key.allocated_at) return -1; + if (lr_a->key.allocated_at > lr_b->key.allocated_at) return 1; return 0; } diff --git a/memcheck/tests/leak-cases-full.stderr.exp b/memcheck/tests/leak-cases-full.stderr.exp index 832e0bbfa9..08447a7cdb 100644 --- a/memcheck/tests/leak-cases-full.stderr.exp +++ b/memcheck/tests/leak-cases-full.stderr.exp @@ -6,42 +6,42 @@ suppressed: 0 bytes in 0 blocks 16 bytes in 1 blocks are possibly lost in loss record ... of ... at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: mk (leak-cases.c:52) - by 0x........: f (leak-cases.c:87) + by 0x........: f (leak-cases.c:78) by 0x........: main (leak-cases.c:107) 16 bytes in 1 blocks are possibly lost in loss record ... of ... at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: mk (leak-cases.c:52) - by 0x........: f (leak-cases.c:87) + by 0x........: f (leak-cases.c:81) by 0x........: main (leak-cases.c:107) 16 bytes in 1 blocks are possibly lost in loss record ... of ... at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: mk (leak-cases.c:52) - by 0x........: f (leak-cases.c:78) + by 0x........: f (leak-cases.c:84) by 0x........: main (leak-cases.c:107) 16 bytes in 1 blocks are possibly lost in loss record ... of ... at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: mk (leak-cases.c:52) - by 0x........: f (leak-cases.c:81) + by 0x........: f (leak-cases.c:84) by 0x........: main (leak-cases.c:107) 16 bytes in 1 blocks are possibly lost in loss record ... of ... at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: mk (leak-cases.c:52) - by 0x........: f (leak-cases.c:84) + by 0x........: f (leak-cases.c:87) by 0x........: main (leak-cases.c:107) 16 bytes in 1 blocks are possibly lost in loss record ... of ... at 0x........: malloc (vg_replace_malloc.c:...) by 0x........: mk (leak-cases.c:52) - by 0x........: f (leak-cases.c:84) + by 0x........: f (leak-cases.c:87) by 0x........: main (leak-cases.c:107)