mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 01:51:29 +00:00
Patch adding (or showing the proper/not confusing) helgrind thread nr for block
and stack address description.
* A race condition on an allocated block shows the stacktrace, but
does not show the thread # that allocated the block.
This patch adds the output of the thread # that allocated the block.
* The patch also fixes the confusion that might appear between
the core threadid and the helgrind thread nr in Stack address description:
A printed stack addrinfo was containing a thread id, while all other helgrind
messages are using (supposed to use) an 'helgrind thread #' which
is used in the thread announcement.
Basically, the idea is to let a tool set a "tool specific thread nr'
in an addrinfo.
The pretty printing of the addrinfo is then by preference showing this
thread nr (if it was set, i.e. different of 0).
Currently, only helgrind uses this addrinfo tnr.
Note: in xml mode, the output is matching the protocol description.
I.e., GUI should not be impacted by this change, if they properly implement
the xml protocol.
* Also, make the output produced by m_addrinfo consistent:
The message 'block was alloc'd at' is changed to be like all other
output : one character indent, and starting with an uppercase
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14175
This commit is contained in:
parent
2e2cea2af6
commit
ef4e827246
2
NEWS
2
NEWS
@ -17,6 +17,8 @@ Release 3.10.0 (?? ?????? 201?)
|
||||
* Helgrind:
|
||||
- Helgrind GDB server monitor command 'info locks' giving
|
||||
the list of locks, their location, and their status.
|
||||
- Race condition error message with allocated blocks also show
|
||||
the thread nr that allocated the racy block.
|
||||
- Helgrind now understands the Ada task termination rules
|
||||
and creates a 'H-B relationship' between a terminated task and
|
||||
its master. This avoids some false positive and avoids big
|
||||
|
||||
@ -105,7 +105,8 @@ void VG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai )
|
||||
UInt f;
|
||||
|
||||
ai->tag = Addr_Stack;
|
||||
ai->Addr.Stack.tid = tid;
|
||||
VG_(initThreadInfo)(&ai->Addr.Stack.tinfo);
|
||||
ai->Addr.Stack.tinfo.tid = tid;
|
||||
ai->Addr.Stack.IP = 0;
|
||||
ai->Addr.Stack.frameNo = -1;
|
||||
/* It is on thread tid stack. Build a stacktrace, and
|
||||
@ -153,6 +154,7 @@ void VG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai )
|
||||
ai->Addr.Block.block_szB = aai.block_szB;
|
||||
ai->Addr.Block.rwoffset = aai.rwoffset;
|
||||
ai->Addr.Block.allocated_at = VG_(null_ExeContext)();
|
||||
VG_(initThreadInfo) (&ai->Addr.Block.alloc_tinfo);
|
||||
ai->Addr.Block.freed_at = VG_(null_ExeContext)();
|
||||
return;
|
||||
}
|
||||
@ -177,6 +179,12 @@ void VG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai )
|
||||
return;
|
||||
}
|
||||
|
||||
void VG_(initThreadInfo) (ThreadInfo *tinfo)
|
||||
{
|
||||
tinfo->tid = 0;
|
||||
tinfo->tnr = 0;
|
||||
}
|
||||
|
||||
void VG_(clear_addrinfo) ( AddrInfo* ai)
|
||||
{
|
||||
switch (ai->tag) {
|
||||
@ -230,6 +238,22 @@ static Bool is_arena_BlockKind(BlockKind bk)
|
||||
}
|
||||
}
|
||||
|
||||
static const HChar* opt_tnr_prefix (ThreadInfo tinfo)
|
||||
{
|
||||
if (tinfo.tnr != 0)
|
||||
return "#";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
static UInt tnr_else_tid (ThreadInfo tinfo)
|
||||
{
|
||||
if (tinfo.tnr != 0)
|
||||
return tinfo.tnr;
|
||||
else
|
||||
return tinfo.tid;
|
||||
}
|
||||
|
||||
static void pp_addrinfo_WRK ( Addr a, AddrInfo* ai, Bool mc, Bool maybe_gcc )
|
||||
{
|
||||
const HChar* xpre = VG_(clo_xml) ? " <auxwhat>" : " ";
|
||||
@ -254,8 +278,11 @@ static void pp_addrinfo_WRK ( Addr a, AddrInfo* ai, Bool mc, Bool maybe_gcc )
|
||||
break;
|
||||
|
||||
case Addr_Stack:
|
||||
VG_(emit)( "%sAddress 0x%llx is on thread %d's stack%s\n",
|
||||
xpre, (ULong)a, ai->Addr.Stack.tid, xpost );
|
||||
VG_(emit)( "%sAddress 0x%llx is on thread %s%d's stack%s\n",
|
||||
xpre, (ULong)a,
|
||||
opt_tnr_prefix (ai->Addr.Stack.tinfo),
|
||||
tnr_else_tid (ai->Addr.Stack.tinfo),
|
||||
xpost );
|
||||
if (ai->Addr.Stack.frameNo != -1 && ai->Addr.Stack.IP != 0) {
|
||||
#define FLEN 256
|
||||
HChar fn[FLEN];
|
||||
@ -344,7 +371,7 @@ static void pp_addrinfo_WRK ( Addr a, AddrInfo* ai, Bool mc, Bool maybe_gcc )
|
||||
VG_(pp_ExeContext)(ai->Addr.Block.freed_at);
|
||||
if (ai->Addr.Block.allocated_at != VG_(null_ExeContext)()) {
|
||||
VG_(emit)(
|
||||
"%s block was alloc'd at%s\n",
|
||||
"%sBlock was alloc'd at%s\n",
|
||||
xpre,
|
||||
xpost
|
||||
);
|
||||
@ -364,7 +391,14 @@ static void pp_addrinfo_WRK ( Addr a, AddrInfo* ai, Bool mc, Bool maybe_gcc )
|
||||
tl_assert (ai->Addr.Block.allocated_at == VG_(null_ExeContext)());
|
||||
tl_assert (ai->Addr.Block.freed_at == VG_(null_ExeContext)());
|
||||
}
|
||||
|
||||
if (ai->Addr.Block.alloc_tinfo.tnr || ai->Addr.Block.alloc_tinfo.tid)
|
||||
VG_(emit)(
|
||||
"%sBlock was alloc'd by thread %s%d%s\n",
|
||||
xpre,
|
||||
opt_tnr_prefix (ai->Addr.Block.alloc_tinfo),
|
||||
tnr_else_tid (ai->Addr.Block.alloc_tinfo),
|
||||
xpost
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ Lock ga 0x........ {
|
||||
by 0x........: th (hg01_all_ok.c:22)
|
||||
by 0x........: mythread_wrapper (hg_intercepts.c:...)
|
||||
...
|
||||
Block was alloc'd by thread #x
|
||||
Lock ga 0x........ {
|
||||
Address 0x........ is 0 bytes inside data symbol "mx"
|
||||
kind mbRec
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "pub_tool_libcbase.h"
|
||||
#include "pub_tool_libcprint.h"
|
||||
#include "pub_tool_libcassert.h"
|
||||
#include "pub_tool_wordfm.h"
|
||||
#include "pub_tool_xarray.h"
|
||||
#include "pub_tool_execontext.h"
|
||||
#include "pub_tool_debuginfo.h"
|
||||
@ -39,14 +40,17 @@
|
||||
#include "pub_tool_addrinfo.h"
|
||||
|
||||
#include "hg_basics.h"
|
||||
#include "hg_wordset.h"
|
||||
#include "hg_lock_n_thread.h"
|
||||
#include "hg_addrdescr.h" /* self */
|
||||
|
||||
void HG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai )
|
||||
{
|
||||
tl_assert(ai->tag == Addr_Undescribed);
|
||||
|
||||
/* hctxt/haddr/hszB describe the addr if it is a heap block. */
|
||||
/* hctxt/tnr/haddr/hszB describe the addr if it is a heap block. */
|
||||
ExeContext* hctxt;
|
||||
UInt tnr;
|
||||
Addr haddr;
|
||||
SizeT hszB;
|
||||
|
||||
@ -58,6 +62,7 @@ void HG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai )
|
||||
Bool is_heapblock
|
||||
= HG_(mm_find_containing_block)(
|
||||
&hctxt,
|
||||
&tnr,
|
||||
&haddr,
|
||||
&hszB,
|
||||
a
|
||||
@ -70,10 +75,27 @@ void HG_(describe_addr) ( Addr a, /*OUT*/AddrInfo* ai )
|
||||
ai->Addr.Block.block_szB = hszB;
|
||||
ai->Addr.Block.rwoffset = (Word)(a) - (Word)(haddr);
|
||||
ai->Addr.Block.allocated_at = hctxt;
|
||||
VG_(initThreadInfo) (&ai->Addr.Block.alloc_tinfo);
|
||||
ai->Addr.Block.alloc_tinfo.tnr = tnr;
|
||||
ai->Addr.Block.freed_at = VG_(null_ExeContext)();;
|
||||
} else {
|
||||
/* No block found. Search a non-heap block description. */
|
||||
VG_(describe_addr) (a, ai);
|
||||
|
||||
/* In case ai contains a tid, set tnr to the corresponding helgrind
|
||||
thread number. */
|
||||
if (ai->tag == Addr_Stack) {
|
||||
Thread* thr = get_admin_threads();
|
||||
|
||||
tl_assert(ai->Addr.Stack.tinfo.tid);
|
||||
while (thr) {
|
||||
if (thr->coretid == ai->Addr.Stack.tinfo.tid) {
|
||||
ai->Addr.Stack.tinfo.tnr = thr->errmsg_index;
|
||||
break;
|
||||
}
|
||||
thr = thr->admin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +59,7 @@ extern Bool HG_(get_and_pp_addrdescr) (Addr a);
|
||||
considered to contain the searched-for address if they equal that
|
||||
address. */
|
||||
Bool HG_(mm_find_containing_block)( /*OUT*/ExeContext** where,
|
||||
/*OUT*/UInt* tnr,
|
||||
/*OUT*/Addr* payload,
|
||||
/*OUT*/SizeT* szB,
|
||||
Addr data_addr );
|
||||
|
||||
@ -865,6 +865,17 @@ void HG_(before_pp_Error) ( Error* err )
|
||||
announce_one_thread( xe->XE.Race.h2_ct );
|
||||
if (xe->XE.Race.h1_ct)
|
||||
announce_one_thread( xe->XE.Race.h1_ct );
|
||||
if (xe->XE.Race.data_addrinfo.Addr.Block.alloc_tinfo.tnr) {
|
||||
Thread* thr = get_admin_threads();
|
||||
while (thr) {
|
||||
if (thr->errmsg_index
|
||||
== xe->XE.Race.data_addrinfo.Addr.Block.alloc_tinfo.tnr) {
|
||||
announce_one_thread (thr);
|
||||
break;
|
||||
}
|
||||
thr = thr->admin;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
tl_assert(0);
|
||||
|
||||
@ -4213,6 +4213,7 @@ static inline Bool addr_is_in_MM_Chunk( MallocMeta* mm, Addr a )
|
||||
}
|
||||
|
||||
Bool HG_(mm_find_containing_block)( /*OUT*/ExeContext** where,
|
||||
/*OUT*/UInt* tnr,
|
||||
/*OUT*/Addr* payload,
|
||||
/*OUT*/SizeT* szB,
|
||||
Addr data_addr )
|
||||
@ -4249,6 +4250,7 @@ Bool HG_(mm_find_containing_block)( /*OUT*/ExeContext** where,
|
||||
tl_assert(mm);
|
||||
tl_assert(addr_is_in_MM_Chunk(mm, data_addr));
|
||||
if (where) *where = mm->where;
|
||||
if (tnr) *tnr = mm->thr->errmsg_index;
|
||||
if (payload) *payload = mm->payload;
|
||||
if (szB) *szB = mm->szB;
|
||||
return True;
|
||||
@ -4868,7 +4870,8 @@ Bool hg_handle_client_request ( ThreadId tid, UWord* args, UWord* ret)
|
||||
SizeT pszB = 0;
|
||||
if (0) VG_(printf)("VG_USERREQ__HG_CLEAN_MEMORY_HEAPBLOCK(%#lx)\n",
|
||||
args[1]);
|
||||
if (HG_(mm_find_containing_block)(NULL, &payload, &pszB, args[1])) {
|
||||
if (HG_(mm_find_containing_block)(NULL, NULL,
|
||||
&payload, &pszB, args[1])) {
|
||||
if (pszB > 0) {
|
||||
evh__die_mem(payload, pszB);
|
||||
evh__new_mem(payload, pszB);
|
||||
|
||||
@ -14,6 +14,10 @@ Thread #x was created
|
||||
by 0x........: barriers_and_races (pth_barrier.c:92)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
|
||||
---Thread-Announcement------------------------------------------
|
||||
|
||||
Thread #x is the program's root thread
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
Possible data race during write of size 1 at 0x........ by thread #x
|
||||
@ -31,4 +35,5 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
|
||||
@ -14,6 +14,10 @@ Thread #x was created
|
||||
by 0x........: barriers_and_races (pth_barrier.c:92)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
|
||||
---Thread-Announcement------------------------------------------
|
||||
|
||||
Thread #x is the program's root thread
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
Possible data race during write of size 1 at 0x........ by thread #x
|
||||
@ -31,6 +35,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -49,6 +54,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -67,6 +73,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -85,6 +92,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -103,6 +111,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -121,6 +130,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -139,6 +149,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -157,6 +168,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -175,6 +187,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -193,6 +206,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -211,6 +225,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -229,6 +244,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -247,6 +263,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -265,6 +282,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -283,6 +301,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -301,6 +320,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -319,6 +339,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -337,6 +358,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -355,6 +377,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -373,6 +396,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -391,6 +415,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -409,6 +434,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -427,6 +453,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -445,6 +472,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -463,6 +491,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -481,6 +510,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -499,6 +529,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -517,6 +548,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -535,6 +567,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -553,6 +586,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -571,6 +605,7 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
@ -589,4 +624,5 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
|
||||
@ -14,6 +14,10 @@ Thread #x was created
|
||||
by 0x........: barriers_and_races (pth_barrier.c:92)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
|
||||
---Thread-Announcement------------------------------------------
|
||||
|
||||
Thread #x is the program's root thread
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
Possible data race during write of size 1 at 0x........ by thread #x
|
||||
@ -31,4 +35,5 @@ Locks held: none
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
by 0x........: barriers_and_races (pth_barrier.c:76)
|
||||
by 0x........: main (pth_barrier.c:122)
|
||||
Block was alloc'd by thread #x
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -75,35 +75,65 @@ typedef
|
||||
}
|
||||
AddrTag;
|
||||
|
||||
/* Note about ThreadInfo tid and tnr in various parts of _Addrinfo:
|
||||
A tid is an index in the VG_(threads)[] array. The entries
|
||||
in VG_(threads) array are re-used, so the tid in an 'old' _Addrinfo
|
||||
might be misleading: if the thread that was using tid has been terminated
|
||||
and the tid was re-used by another thread, the tid will very probably
|
||||
be wrongly interpreted by the user.
|
||||
So, such an _Addrinfo should be printed just after it has been produced,
|
||||
before the tid could possibly be re-used by another thread.
|
||||
|
||||
A tool such as helgrind is uniquely/unambiguously identifying each thread
|
||||
by a number. If the tool sets tnr between the call to
|
||||
VG_(describe_addr) and the call to VG_(pp_addrinfo), then VG_(pp_addrinfo)
|
||||
will by preference print tnr instead of tid.
|
||||
Visually, a tid will be printed as thread %d
|
||||
while a tnr will be printed as thread #%d
|
||||
*/
|
||||
|
||||
typedef
|
||||
struct _ThreadInfo {
|
||||
ThreadId tid; // 0 means thread not known.
|
||||
UInt tnr; // 0 means no tool specific thread nr, or not known.
|
||||
} ThreadInfo;
|
||||
|
||||
/* Zeroes/clear all the fields of *tinfo. */
|
||||
extern void VG_(initThreadInfo) (ThreadInfo *tinfo);
|
||||
|
||||
typedef
|
||||
struct _AddrInfo
|
||||
AddrInfo;
|
||||
|
||||
|
||||
struct _AddrInfo {
|
||||
AddrTag tag;
|
||||
union {
|
||||
// As-yet unclassified.
|
||||
struct { } Undescribed;
|
||||
|
||||
// On a stack. tid indicates which thread's stack?
|
||||
// On a stack. tinfo indicates which thread's stack?
|
||||
// IP is the address of an instruction of the function where the
|
||||
// stack address was. 0 if not found.
|
||||
// frameNo is the frame nr of the call where the stack address was.
|
||||
// -1 if not found.
|
||||
struct {
|
||||
ThreadId tid;
|
||||
ThreadInfo tinfo;
|
||||
Addr IP;
|
||||
Int frameNo;
|
||||
} Stack;
|
||||
|
||||
// This covers heap blocks (normal and from mempools), user-defined
|
||||
// blocks and Arena blocks.
|
||||
// alloc_tinfo identifies the thread that has allocated the block.
|
||||
// This is used by tools such as helgrind that maintain
|
||||
// more detailed informations about client blocks.
|
||||
struct {
|
||||
BlockKind block_kind;
|
||||
const HChar* block_desc; // "block","mempool","user-defined",arena
|
||||
SizeT block_szB;
|
||||
PtrdiffT rwoffset;
|
||||
ExeContext* allocated_at; // might be null_ExeContext.
|
||||
ThreadInfo alloc_tinfo; // which thread did alloc this block.
|
||||
ExeContext* freed_at; // might be null_ExeContext.
|
||||
} Block;
|
||||
|
||||
|
||||
@ -827,6 +827,7 @@ void MC_(record_freemismatch_error) ( ThreadId tid, MC_Chunk* mc )
|
||||
ai->Addr.Block.block_szB = mc->szB;
|
||||
ai->Addr.Block.rwoffset = 0;
|
||||
ai->Addr.Block.allocated_at = MC_(allocated_at) (mc);
|
||||
VG_(initThreadInfo) (&ai->Addr.Block.alloc_tinfo);
|
||||
ai->Addr.Block.freed_at = MC_(freed_at) (mc);
|
||||
VG_(maybe_record_error)( tid, Err_FreeMismatch, mc->data, /*s*/NULL,
|
||||
&extra );
|
||||
@ -1035,6 +1036,7 @@ static void describe_addr ( Addr a, /*OUT*/AddrInfo* ai )
|
||||
ai->Addr.Block.block_szB = mc->szB;
|
||||
ai->Addr.Block.rwoffset = (Word)a - (Word)mc->data;
|
||||
ai->Addr.Block.allocated_at = MC_(allocated_at)(mc);
|
||||
VG_(initThreadInfo) (&ai->Addr.Block.alloc_tinfo);
|
||||
ai->Addr.Block.freed_at = MC_(freed_at)(mc);
|
||||
return;
|
||||
}
|
||||
@ -1048,6 +1050,7 @@ static void describe_addr ( Addr a, /*OUT*/AddrInfo* ai )
|
||||
ai->Addr.Block.block_szB = mc->szB;
|
||||
ai->Addr.Block.rwoffset = (Word)a - (Word)mc->data;
|
||||
ai->Addr.Block.allocated_at = MC_(allocated_at)(mc);
|
||||
VG_(initThreadInfo) (&ai->Addr.Block.alloc_tinfo);
|
||||
ai->Addr.Block.freed_at = MC_(freed_at)(mc);
|
||||
return;
|
||||
}
|
||||
@ -1182,6 +1185,7 @@ static Bool client_block_maybe_describe( Addr a,
|
||||
ai->Addr.Block.block_szB = cgbs[i].size;
|
||||
ai->Addr.Block.rwoffset = (Word)(a) - (Word)(cgbs[i].start);
|
||||
ai->Addr.Block.allocated_at = cgbs[i].where;
|
||||
VG_(initThreadInfo) (&ai->Addr.Block.alloc_tinfo);
|
||||
ai->Addr.Block.freed_at = VG_(null_ExeContext)();;
|
||||
return True;
|
||||
}
|
||||
@ -1209,6 +1213,7 @@ static Bool mempool_block_maybe_describe( Addr a,
|
||||
ai->Addr.Block.block_szB = mc->szB;
|
||||
ai->Addr.Block.rwoffset = (Word)a - (Word)mc->data;
|
||||
ai->Addr.Block.allocated_at = MC_(allocated_at)(mc);
|
||||
VG_(initThreadInfo) (&ai->Addr.Block.alloc_tinfo);
|
||||
ai->Addr.Block.freed_at = MC_(freed_at)(mc);
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ Invalid write of size 1
|
||||
...
|
||||
Address 0x........ is 1 bytes inside a block of size 10 free'd
|
||||
...
|
||||
block was alloc'd at
|
||||
Block was alloc'd at
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
...
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ Invalid write of size 1
|
||||
Address 0x........ is 1 bytes inside a block of size 10 free'd
|
||||
at 0x........: free (vg_replace_malloc.c:...)
|
||||
...
|
||||
block was alloc'd at
|
||||
Block was alloc'd at
|
||||
at 0x........: malloc (vg_replace_malloc.c:...)
|
||||
...
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user