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

Kostya Serebryany kcc at google.com
Mon Jul 27 12:43:58 PDT 2015


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150727/a5fdaa96/attachment.html>


More information about the llvm-commits mailing list