[compiler-rt] r261986 - [TSAN] XFAIL race_on_mutex.cc for MIPS

Alexey Samsonov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 29 11:00:28 PST 2016


On Mon, Feb 29, 2016 at 5:09 AM, sagar <sagar.thakur at imgtec.com> wrote:

> Hi,
>
> The stack trace produced by TSan is:
>
>   Previous write of size 8 at 0x0120ed2930 by thread T1:
>     #0 memset
> /home/slt/LLVM/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:678
> (race_on_mutex.c.tmp+0x0120071808)
>     #1 __GI___pthread_mutex_init
> /build/glibc-g99ldr/glibc-2.19/nptl/pthread_mutex_init.c:84
> (libpthread.so.0+0x000000d634)
>     #2 <null>
> /home/slt/LLVM/llvm/projects/compiler-rt/test/tsan/race_on_mutex.c:11
> (race_on_mutex.c.tmp+0x01200ea59c)
>
> 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.
> Should we adjust the expected output?
>

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,
which calls memset(), and TSan records this memset as "memory write",
instead of explicit "MemoryWrite()" from MutexCreate()?

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
accessed by the actual libc/libpthread function before we call this actual
function. Maybe, we can follow the same approach here, and call
MemoryWrite()
on mutex from mutex-related interceptors before we're calling the "real"
function. Dmitry, WDYT?


>
> Modified: compiler-rt/trunk/test/tsan/race_on_mutex.c
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_mutex.c?rev=261986&r1=261985&r2=261986&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/test/tsan/race_on_mutex.c (original)
> +++ compiler-rt/trunk/test/tsan/race_on_mutex.c Fri Feb 26 01:01:24 2016
> @@ -2,6 +2,10 @@
>  // This test fails when run on powerpc64 (VMA=46).
>  // The size of the write reported by Tsan for T1 is 8 instead of 1.
>  // XFAIL: powerpc64
> +// This test expects pthread_mutex_init in the frame #0 of thread T1 but
> we
> +// get memset at frame #0 because memset that is called from
> pthread_init_mutex
>
> ^^
> Seems that you're missing a verb or a preposition in this sentence.
> Also, pthread_mutex_init, not pthread_init_mutex.
>
> Sorry, I'll correct it.
>
>
> On Saturday 27 February 2016 12:55 AM, Alexey Samsonov wrote:
>
> 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,
> or improve the runtime so that it would in fact produce pthread_mutex_init
> as frame #0.
>
> On Thu, Feb 25, 2016 at 11:01 PM, Sagar Thakur via llvm-commits <
> <llvm-commits at lists.llvm.org>llvm-commits at lists.llvm.org> wrote:
>
>> Author: slthakur
>> Date: Fri Feb 26 01:01:24 2016
>> New Revision: 261986
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=261986&view=rev
>> Log:
>> [TSAN] XFAIL race_on_mutex.cc for MIPS
>>
>> This test expects pthread_mutex_init in the frame #0 of thread T1 but we
>> get memset at frame #0 because memset that is called from
>> pthread_init_mutex
>> is being intercepted by TSan
>>
>>
>> Modified:
>>     compiler-rt/trunk/test/tsan/race_on_mutex.c
>>
>> Modified: compiler-rt/trunk/test/tsan/race_on_mutex.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/race_on_mutex.c?rev=261986&r1=261985&r2=261986&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/test/tsan/race_on_mutex.c (original)
>> +++ compiler-rt/trunk/test/tsan/race_on_mutex.c Fri Feb 26 01:01:24 2016
>> @@ -2,6 +2,10 @@
>>  // This test fails when run on powerpc64 (VMA=46).
>>  // The size of the write reported by Tsan for T1 is 8 instead of 1.
>>  // XFAIL: powerpc64
>> +// This test expects pthread_mutex_init in the frame #0 of thread T1 but
>> we
>> +// get memset at frame #0 because memset that is called from
>> pthread_init_mutex
>>
>
> ^^
> Seems that you're missing a verb or a preposition in this sentence.
> Also, pthread_mutex_init, not pthread_init_mutex.
>
>
>> +// is being intercepted by TSan
>> +// XFAIL: mips64
>>  #include "test.h"
>>
>>  pthread_mutex_t Mtx;
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
>
> --
> Alexey Samsonov
> vonosmas at gmail.com
>
>
>


-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160229/8753b829/attachment.html>


More information about the llvm-commits mailing list