diff mbox

[5/7] Libsanitizer merge from upstream r249633.

Message ID 561E816D.9050901@partner.samsung.com
State New
Headers show

Commit Message

max Oct. 14, 2015, 4:23 p.m. UTC
On 14/10/15 10:37, Jakub Jelinek wrote:
> On Tue, Oct 13, 2015 at 02:20:06PM +0300, Maxim Ostapenko wrote:
>> This patch removes UBSan stubs from ASan and TSan code. We don't embed UBSan
>> to ASan and UBSan because that would lead to undefined references to C++
>> stuff when linking with -static-libasan. AFAIK, sanitizer developers use
>> different libraries for C and CXX runtimes, but I think this is out of scope
>> of this merge.
> Where is CAN_SANITIZE_UB defined?  I don't see it anywhere in the current
> libsanitizer and in the patch only:
> grep CAN_SANITIZE_UB libsanitizer-249633-2.diff
> +#if CAN_SANITIZE_UB
> +# define TSAN_CONTAINS_UBSAN (CAN_SANITIZE_UB && !defined(SANITIZER_GO))
> +#if CAN_SANITIZE_UB
> +#endif  // CAN_SANITIZE_UB
> +#if CAN_SANITIZE_UB
> +#endif  // CAN_SANITIZE_UB
> +#if CAN_SANITIZE_UB
> +#endif  // CAN_SANITIZE_UB
> +#if CAN_SANITIZE_UB
> +#endif  // CAN_SANITIZE_UB
> +#if CAN_SANITIZE_UB
> +#endif  // CAN_SANITIZE_UB
> +#if CAN_SANITIZE_UB
> +#endif  // CAN_SANITIZE_UB
> +#if CAN_SANITIZE_UB
> +#endif  // CAN_SANITIZE_UB

Hm, this is strange, perhaps the patch was malformed.

>
> So, unless I'm missing something, it would be best to arrange for
> -DCAN_SANITIZE_UB=1 to be in CXXFLAGS for ubsan/ source files and
> -DCAN_SANITIZE_UB=0 to be in CXXFLAGS for {a,t}san/ source files?

CAN_SANITIZE_UB definition is hardcoded into new ubsan/ubsan_platform.h 
file. To use DCAN_SANITIZE_UB from CXXFLAGS, we still need some changes 
in libsanitizer against upstream:

      (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || \
@@ -23,5 +24,6 @@
  #else
  # define CAN_SANITIZE_UB 0
  #endif
+#endif // CAN_SANITIZE_UB

  #endif

> Are there any other defines that are supposedly set from cmake or wherever
> upstream and are left undefined?

There is ASAN_DYNAMIC macro, but I see it into current libsanitizer too 
and it's not touched in any Makefile. Same for 
ASAN_DYNAMIC_RUNTIME_THUNK, that is used for Windows build and 
ASAN_LOW_MEMORY, that set explicitly only for Android. Do we need to 
touch them?
Also, ASAN_FLEXIBLE_MAPPING_AND_OFFSET was bumped upstream, so we don't 
need it anymore.

I'm applying the patch mentioned above, redefining CAN_SANITIZE_UB in 
corresponding Makefiles, dropping ASAN_FLEXIBLE_MAPPING_AND_OFFSET and 
resending libsanitizer-249633-2.diff in corresponding thread.
>> 2015-10-13  Maxim Ostapenko  <m.ostapenko@partner.samsung.com>
>>
>> 	* tsan/tsan_defs.h: Define TSAN_CONTAINS_UBSAN to 0.
>> 	* asan/asan_flags.cc (InitializeFlags): Do not initialize UBSan flags.
>> 	* asan/asan_rtl.cc (AsanInitInternal): Do not init UBSan.
> 	Jakub
>
diff mbox

Patch

Index: libsanitizer/ubsan/ubsan_platform.h
===================================================================
--- libsanitizer/ubsan/ubsan_platform.h    (revision 250295)
+++ libsanitizer/ubsan/ubsan_platform.h    (working copy)
@@ -13,6 +13,7 @@ 
  #ifndef UBSAN_PLATFORM_H
  #define UBSAN_PLATFORM_H

+#ifndef CAN_SANITIZE_UB
  // Other platforms should be easy to add, and probably work as-is.
  #if (defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)) 
&& \