diff options
author | Andrey Kazmin <a.kazmin@partner.samsung.com> | 2020-04-14 12:12:13 +0300 |
---|---|---|
committer | Andrey Kazmin <a.kazmin@partner.samsung.com> | 2020-05-07 12:37:43 +0300 |
commit | 95bd392c0e11710bb0c6a179b1a606c6f8c969f5 (patch) | |
tree | 67ef72b16b2f82703b6e1668f5f532fa84fa4045 | |
parent | 9df87a133b0f29f4932f38b7307c87d09ab80d5d (diff) | |
download | coreclr-sandbox/akazmin/asan_annotate_buff.tar.gz coreclr-sandbox/akazmin/asan_annotate_buff.tar.bz2 coreclr-sandbox/akazmin/asan_annotate_buff.zip |
Annotate CLR to native buffers for ASan runtimesandbox/akazmin/asan_annotate_buff
Signed-off-by: Andrey Kazmin <a.kazmin@partner.samsung.com>
-rw-r--r-- | src/pal/src/memory/local.cpp | 32 | ||||
-rw-r--r-- | src/vm/ilmarshalers.cpp | 3 |
2 files changed, 33 insertions, 2 deletions
diff --git a/src/pal/src/memory/local.cpp b/src/pal/src/memory/local.cpp index 3a0f40f8c4..9fba1d12df 100644 --- a/src/pal/src/memory/local.cpp +++ b/src/pal/src/memory/local.cpp @@ -26,6 +26,14 @@ Revision History: SET_DEFAULT_DEBUG_CHANNEL(MEM); +#ifdef TIZEN_ASAN_ENVIRONMENT +extern "C" { +extern void __sanitizer_disable_interceptors() __attribute__ ((weak)); +extern void __sanitizer_enable_interceptors() __attribute__ ((weak)); +extern bool __sanitizer_interceptors_are_enabled() __attribute__ ((weak)); +} +#endif + static int AllocFlagsToHeapAllocFlags (IN UINT AllocFlags, @@ -70,7 +78,18 @@ LocalAlloc( goto done; } +#ifdef TIZEN_ASAN_ENVIRONMENT + _ASSERTE(__sanitizer_interceptors_are_enabled != NULL); + bool san_enabled; + san_enabled = __sanitizer_interceptors_are_enabled(); + if (!san_enabled) + __sanitizer_enable_interceptors(); + lpRetVal = HeapAlloc( GetProcessHeap(), uFlags, uBytes ); + if (!san_enabled) + __sanitizer_disable_interceptors(); +#else lpRetVal = HeapAlloc( GetProcessHeap(), uFlags, uBytes ); +#endif done: LOGEXIT( "LocalAlloc returning %p.\n", lpRetVal ); @@ -128,7 +147,18 @@ LocalFree( if ( hMem ) { - bRetVal = HeapFree( GetProcessHeap(), 0, hMem ); +#ifdef TIZEN_ASAN_ENVIRONMENT + _ASSERTE(__sanitizer_interceptors_are_enabled != NULL); + bool san_enabled; + san_enabled = __sanitizer_interceptors_are_enabled(); + if (!san_enabled) + __sanitizer_enable_interceptors(); + bRetVal = HeapFree( GetProcessHeap(), 0, hMem ); + if (!san_enabled) + __sanitizer_disable_interceptors(); +#else + bRetVal = HeapFree( GetProcessHeap(), 0, hMem ); +#endif } else { diff --git a/src/vm/ilmarshalers.cpp b/src/vm/ilmarshalers.cpp index a89aeaf2a1..9e7ee17484 100644 --- a/src/vm/ilmarshalers.cpp +++ b/src/vm/ilmarshalers.cpp @@ -3808,11 +3808,12 @@ void ILMngdMarshaler::EmitCallMngdMarshalerMethod(ILCodeStream* pslILEmit, Metho bool ILNativeArrayMarshaler::UsePinnedArraySpecialCase() { +#ifndef TIZEN_ASAN_ENVIRONMENT if (IsCLRToNative(m_dwMarshalFlags) && !IsByref(m_dwMarshalFlags) && (NULL != m_pargs->na.m_pArrayMT) && (NULL == OleVariant::GetMarshalerForVarType(m_pargs->na.m_vt, TRUE))) { return true; } - +#endif return false; } |