<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Feb 29, 2016 at 5:09 AM, sagar <span dir="ltr"><<a href="mailto:sagar.thakur@imgtec.com" target="_blank">sagar.thakur@imgtec.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
The stack trace produced by TSan is:<br>
<br>
Previous write of size 8 at 0x0120ed2930 by thread T1:<br>
#0 memset
/home/slt/LLVM/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:678
(race_on_mutex.c.tmp+0x0120071808)<br>
#1 __GI___pthread_mutex_init
/build/glibc-g99ldr/glibc-2.19/nptl/pthread_mutex_init.c:84
(libpthread.so.0+0x000000d634)<br>
#2 <null>
/home/slt/LLVM/llvm/projects/compiler-rt/test/tsan/race_on_mutex.c:11
(race_on_mutex.c.tmp+0x01200ea59c)<br>
<br>
The actual cause may be that the memset call at
pthread_mutex_init.c:84 is not in-lined for mips where as it is
in-lined for x86 targets.<br>
Should we adjust the expected output?</div></blockquote><div><br></div><div>So, do I understand correctly that on MIPS we do call pthread_mutex_init() interceptor, which then calls real pthread_mutext_init() from libpthread.so,<br></div><div>which calls memset(), and TSan records this memset as "memory write", instead of explicit "MemoryWrite()" from MutexCreate()?</div><div><br></div><div>If that's the case, then we can consider fixing the interceptor code instead. Generally, in sanitizers we annotate that a certain memory region will be</div><div>accessed by the actual libc/libpthread function before we call this actual function. Maybe, we can follow the same approach here, and call MemoryWrite()</div><div>on mutex from mutex-related interceptors before we're calling the "real" function. Dmitry, WDYT?</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class=""><br>
<blockquote type="cite">Modified:
compiler-rt/trunk/test/tsan/race_on_mutex.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_mutex.c?rev=261986&r1=261985&r2=261986&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_mutex.c?rev=261986&r1=261985&r2=261986&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/race_on_mutex.c (original)<br>
+++ compiler-rt/trunk/test/tsan/race_on_mutex.c Fri Feb 26
01:01:24 2016<br>
@@ -2,6 +2,10 @@<br>
// This test fails when run on powerpc64 (VMA=46).<br>
// The size of the write reported by Tsan for T1 is 8 instead of
1.<br>
// XFAIL: powerpc64<br>
+// This test expects pthread_mutex_init in the frame #0 of thread
T1 but we<br>
+// get memset at frame #0 because memset that is called from
pthread_init_mutex<br>
<div><br>
</div>
<div>^^</div>
<div>Seems that you're missing a verb or a preposition in this
sentence.</div>
<div>Also, pthread_mutex_init, not pthread_init_mutex.</div>
</blockquote></span>
Sorry, I'll correct it.<div><div class="h5"><br>
<br>
<div>On Saturday 27 February 2016 12:55 AM,
Alexey Samsonov wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">So, what is the stack trace produced by
TSan? I don't see why we should XFAIL the test - we can either
adjust the expectation,</div>
<div class="gmail_extra">or improve the runtime so that it would
in fact produce pthread_mutex_init as frame #0.</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Feb 25, 2016 at 11:01 PM,
Sagar Thakur via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank"></a><a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author:
slthakur<br>
Date: Fri Feb 26 01:01:24 2016<br>
New Revision: 261986<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=261986&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=261986&view=rev</a><br>
Log:<br>
[TSAN] XFAIL race_on_mutex.cc for MIPS<br>
<br>
This test expects pthread_mutex_init in the frame #0 of
thread T1 but we<br>
get memset at frame #0 because memset that is called from
pthread_init_mutex<br>
is being intercepted by TSan<br>
<br>
<br>
Modified:<br>
compiler-rt/trunk/test/tsan/race_on_mutex.c<br>
<br>
Modified: compiler-rt/trunk/test/tsan/race_on_mutex.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_mutex.c?rev=261986&r1=261985&r2=261986&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_mutex.c?rev=261986&r1=261985&r2=261986&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/test/tsan/race_on_mutex.c (original)<br>
+++ compiler-rt/trunk/test/tsan/race_on_mutex.c Fri Feb 26
01:01:24 2016<br>
@@ -2,6 +2,10 @@<br>
// This test fails when run on powerpc64 (VMA=46).<br>
// The size of the write reported by Tsan for T1 is 8
instead of 1.<br>
// XFAIL: powerpc64<br>
+// This test expects pthread_mutex_init in the frame #0
of thread T1 but we<br>
+// get memset at frame #0 because memset that is called
from pthread_init_mutex<br>
</blockquote>
<div><br>
</div>
<div>^^</div>
<div>Seems that you're missing a verb or a preposition in
this sentence.</div>
<div>Also, pthread_mutex_init, not pthread_init_mutex.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+// is being intercepted by TSan<br>
+// XFAIL: mips64<br>
#include "test.h"<br>
<br>
pthread_mutex_t Mtx;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div>
<div dir="ltr">Alexey Samsonov<br>
<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div>
</div>
</div>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div></div>