[compiler-rt] r243241 - tsan: fix shift overflow

Dmitry Vyukov dvyukov at google.com
Mon Jul 27 13:00:25 PDT 2015


I miserably failed to acknowledge the right tool. I did not run it
under ubsan. It is a new gcc warning that caught it:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67009




On Mon, Jul 27, 2015 at 9:43 PM, Kostya Serebryany <kcc at google.com> wrote:
> wow!
> Did you run tsan under ubsan?
>
> On Sun, Jul 26, 2015 at 12:45 AM, Dmitry Vyukov <dvyukov at google.com> wrote:
>>
>> Author: dvyukov
>> Date: Sun Jul 26 02:45:26 2015
>> New Revision: 243241
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=243241&view=rev
>> Log:
>> tsan: fix shift overflow
>>
>> 3<<30 fits into 32-bit unsigned, but does not fit into int.
>> Found by ubsan.
>>
>>
>> Modified:
>>     compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h
>>
>> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h?rev=243241&r1=243240&r2=243241&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h (original)
>> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h Sun Jul 26 02:45:26 2015
>> @@ -86,9 +86,9 @@ class MetaMap {
>>    void OnThreadIdle(ThreadState *thr);
>>
>>   private:
>> -  static const u32 kFlagMask  = 3 << 30;
>> -  static const u32 kFlagBlock = 1 << 30;
>> -  static const u32 kFlagSync  = 2 << 30;
>> +  static const u32 kFlagMask  = 3u << 30;
>> +  static const u32 kFlagBlock = 1u << 30;
>> +  static const u32 kFlagSync  = 2u << 30;
>>    typedef DenseSlabAlloc<MBlock, 1<<16, 1<<12> BlockAlloc;
>>    typedef DenseSlabAlloc<SyncVar, 1<<16, 1<<10> SyncAlloc;
>>    BlockAlloc block_alloc_;
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>



More information about the llvm-commits mailing list