Skip to content

Commit 1c13aa3

Browse files
committed
Try fixing ubsan
1 parent e19b117 commit 1c13aa3

5 files changed

Lines changed: 15 additions & 21 deletions

File tree

profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ if (RUN_ASAN)
3030
endif()
3131

3232
if (RUN_UBSAN)
33-
add_compile_options(-fsanitize=undefined -g -fno-omit-frame-pointer -fno-sanitize-recover=all -DDD_SANITIZERS)
34-
if (ISARM64)
35-
# On arm64, the CLR exports typeinfo for ProfToEEInterfaceImpl, so UBSAN's vptr
36-
# check fires on every call through CLR interface pointers. Suppress vptr checks
37-
# only for CLR COM types (IUnknown, ICorProfilerInfo*, ICorProfilerCallback*).
38-
# On x86_64 the CLR doesn't export that typeinfo, so the check is silently skipped.
39-
add_compile_options(-fsanitize-ignorelist=${CMAKE_SOURCE_DIR}/profiler/src/ProfilerEngine/ubsan_ignorelist.txt)
40-
endif()
33+
add_compile_options(-fsanitize=undefined -g -fno-omit-frame-pointer -DDD_SANITIZERS)
4134
endif()
4235

4336
if (RUN_TSAN)

profiler/src/ProfilerEngine/Datadog.Profiler.Native/CorProfilerCallback.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,12 @@ ULONG STDMETHODCALLTYPE CorProfilerCallback::GetRefCount() const
11211121
return refCount;
11221122
}
11231123

1124+
// On arm64, the CLR exports typeinfo for ProfToEEInterfaceImpl, so UBSAN's vptr
1125+
// check fires on calls through COM interface pointers. On x86_64 the CLR does
1126+
// not export that typeinfo, so the check is silently skipped.
1127+
#if defined(__clang__) && defined(ARM64)
1128+
__attribute__((no_sanitize("vptr")))
1129+
#endif
11241130
void CorProfilerCallback::InspectRuntimeCompatibility(IUnknown* corProfilerInfoUnk, uint16_t& runtimeMajor, uint16_t& runtimeMinor)
11251131
{
11261132
runtimeMajor = 0;
@@ -1305,6 +1311,9 @@ void CorProfilerCallback::InspectProcessorInfo()
13051311
#endif
13061312
}
13071313

1314+
#if defined(__clang__) && defined(ARM64)
1315+
__attribute__((no_sanitize("vptr")))
1316+
#endif
13081317
void CorProfilerCallback::InspectRuntimeVersion(ICorProfilerInfo5* pCorProfilerInfo, USHORT& major, USHORT& minor, COR_PRF_RUNTIME_TYPE& runtimeType)
13091318
{
13101319
USHORT clrInstanceId;
@@ -1399,6 +1408,9 @@ void CorProfilerCallback::PrintEnvironmentVariables()
13991408
const uint32_t InformationalVerbosity = 4;
14001409
const uint32_t VerboseVerbosity = 5;
14011410

1411+
#if defined(__clang__) && defined(ARM64)
1412+
__attribute__((no_sanitize("vptr")))
1413+
#endif
14021414
HRESULT STDMETHODCALLTYPE CorProfilerCallback::Initialize(IUnknown* corProfilerInfoUnk)
14031415
{
14041416
Log::Info("CorProfilerCallback is initializing.");

profiler/src/ProfilerEngine/ubsan_ignorelist.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

profiler/test/Datadog.Linux.ApiWrapper.Tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (RUN_ASAN)
1818
endif()
1919

2020
if (RUN_UBSAN)
21-
add_compile_options(-fsanitize=undefined -g -fno-omit-frame-pointer -fno-sanitize-recover=all)
21+
add_compile_options(-fsanitize=undefined -g -fno-omit-frame-pointer)
2222
endif()
2323

2424
if(ISLINUX)

profiler/test/Datadog.Profiler.Native.Tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (RUN_ASAN)
2222
endif()
2323

2424
if (RUN_UBSAN)
25-
add_compile_options(-fsanitize=undefined -g -fno-omit-frame-pointer -fno-sanitize-recover=all)
25+
add_compile_options(-fsanitize=undefined -g -fno-omit-frame-pointer)
2626
endif()
2727

2828
if (RUN_TSAN)

0 commit comments

Comments
 (0)