summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Cherkashin <v.cherkashin@samsung.com>2019-07-29 15:10:40 (GMT)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>2019-07-29 15:10:40 (GMT)
commit58f37b76b0a094cf5a1e7211ce3f745f41d2888b (patch)
tree0f481df827b3016349045749b8210d2474dc3d55
parentfd696ae56964f5e08ffe09b4acf1221bfed0de59 (diff)
downloadcoreclr-58f37b76b0a094cf5a1e7211ce3f745f41d2888b.zip
coreclr-58f37b76b0a094cf5a1e7211ce3f745f41d2888b.tar.gz
coreclr-58f37b76b0a094cf5a1e7211ce3f745f41d2888b.tar.bz2
DEBUG: add __sanitizer_interceptors_are_enabled() checker to Internal...()
Change-Id: I1c3c2d330694ae7700d5f65e2e2928c1d9f3b008 Signed-off-by: Vyacheslav Cherkashin <v.cherkashin@samsung.com>
-rw-r--r--src/pal/src/cruntime/malloc.cpp25
-rw-r--r--src/pal/src/include/pal/malloc.hpp9
2 files changed, 31 insertions, 3 deletions
diff --git a/src/pal/src/cruntime/malloc.cpp b/src/pal/src/cruntime/malloc.cpp
index 3083a20..1033381 100644
--- a/src/pal/src/cruntime/malloc.cpp
+++ b/src/pal/src/cruntime/malloc.cpp
@@ -29,6 +29,17 @@ Revision History:
SET_DEFAULT_DEBUG_CHANNEL(CRT);
+
+extern "C" bool __sanitizer_interceptors_are_enabled();
+extern "C" int dprintf(int fd, const char *format, ...);
+
+#define CHECK_ASAN() \
+ do { \
+ if (__sanitizer_interceptors_are_enabled()) {
+ dprintf("####### %s: %s +%d\n", __func__, __FILE__, __LINE__);
+ }
+ } while (0)
+
using namespace CorUnix;
void *
@@ -49,6 +60,7 @@ CorUnix::InternalRealloc(
{
void *pvMem;
+ CHECK_ASAN();
PERF_ENTRY(InternalRealloc);
ENTRY("realloc (memblock:%p size=%d)\n", pvMemblock, szSize);
@@ -72,12 +84,21 @@ CorUnix::InternalRealloc(
}
void
+CoreUnix::InternalFree(
+ void *pMem
+ )
+{
+ CHECK_ASAN();
+ free(pvMem);
+}
+
+void
__cdecl
PAL_free(
void *pvMem
)
{
- free(pvMem);
+ InternalFree(pvMem);
}
void *
@@ -96,6 +117,7 @@ CorUnix::InternalMalloc(
{
void *pvMem;
+ CHECK_ASAN();
if (szSize == 0)
{
// malloc may return null for a requested size of zero bytes. Force a nonzero size to get a valid pointer.
@@ -112,5 +134,6 @@ PAL__strdup(
const char *c_szStr
)
{
+ CHECK_ASAN();
return strdup(c_szStr);
} \ No newline at end of file
diff --git a/src/pal/src/include/pal/malloc.hpp b/src/pal/src/include/pal/malloc.hpp
index 580b6a9..0372428 100644
--- a/src/pal/src/include/pal/malloc.hpp
+++ b/src/pal/src/include/pal/malloc.hpp
@@ -68,6 +68,11 @@ namespace CorUnix{
size_t szSize
);
+ void
+ InternalFree(
+ void *pvMem
+ );
+
// Define common code for "new" style allocators below.
#define INTERNAL_NEW_COMMON() \
T *pMem = (T*)InternalMalloc(sizeof(T)); \
@@ -146,7 +151,7 @@ namespace CorUnix{
if (p)
{
p->~T();
- free(p);
+ InternalFree(p);
}
}
@@ -158,7 +163,7 @@ namespace CorUnix{
size_t cElements = *pRealMem;
for (size_t i = 0; i < cElements; i++)
p[i].~T();
- free(pRealMem);
+ InternalFree(pRealMem);
}
}
}