|
From: Julian S. <js...@ac...> - 2008-05-04 09:31:23
|
> As you know on Linux the NPTL allocates space on the top of the stack
> for NPTL-private data. This data is accessed by more than one thread.
> In order to avoid false positives on this NPTL-private data I let DRD
> suppress data race reports on data accesses in the NPTL-private data
> area.
What happens if NPTL puts some thread private data in some other
place? Then DRD complains again. I saw the same problem in
Helgrind but simply decided to suppress all errors that it
reports inside libpthread.
But anyway. I think
husa = (nframes >= 1 ? sps[nframes - 1] : VG_(get_SP)(vg_tid));
is not good. I added this
VG_(printf)("\n\ngetting stack for tid %d\n", (Int)vg_tid);
VG_(pp_ExeContext)( VG_(record_ExeContext)( vg_tid, 0 ));
just before your call to VG_(get_StackTrace), and
VG_(printf)("nframes = %d\n", nframes);
{Int i; for (i = 0; i < 10; i++)
VG_(printf)("sps[%d] = %p\n", i, sps[i]);}
just after. What it shows is:
getting stack for tid 1
==27412== at 0xFF7C4D8: init (drd_pthread_intercepts.c:244)
==27412== by 0xFF7CDD4:
(within /home/sewardj/VgTRUNK/trunk/exp-drd/vgpreload_exp-drd-ppc32-linux.so)
==27412== by 0xFF75D3C:
(within /home/sewardj/VgTRUNK/trunk/exp-drd/vgpreload_exp-drd-ppc32-linux.so)
==27412== by 0xFFCEC28: call_init (in /lib/ld-2.7.so)
==27412== by 0xFFCEDAC: _dl_init (in /lib/ld-2.7.so)
==27412== by 0xFFD70A0: _start (in /lib/ld-2.7.so)
nframes = 6
sps[0] = 0xFEA04790
sps[1] = 0xFEA048D0
sps[2] = 0xFEA048E0
sps[3] = 0xFEA04910
sps[4] = 0xFEA04940
sps[5] = 0x0
sps[6] = 0x0
sps[7] = 0x0
sps[8] = 0x46AAD70
sps[9] = 0xFFFFFFFF
So you get husa = sps[n_frames - 1] = sps[5] = 0, which is bogus.
This strikes me as much safer:
if (0) {
husa = (nframes >= 1 ? sps[nframes - 1] : VG_(get_SP)(vg_tid));
} else {
UInt i;
tl_assert(nframes >= 1 && nframes <= n_ips);
husa = sps[0];
for (i = 1; i < nframes; i++) {
if (sps[i] == 0) break;
if (sps[i] > husa) husa = sps[i];
}
}
This produces husa = 0xFEA04940, the assertion does not fail, and drd
does not go into outer space. (It was taking about 1GB just to run
/bin/ls before this).
Nuno, can you try that?
J
|