- made some changes to let the engine start up with ASAN enabled on MSVC.

This commit is contained in:
Christoph Oelckers 2022-10-19 18:01:28 +02:00
parent 1553ec812d
commit c51a71ed94
2 changed files with 11 additions and 5 deletions

View file

@ -47,6 +47,12 @@
#define NO_SANITIZE #define NO_SANITIZE
#endif #endif
#if defined _MSC_VER
#define NO_SANITIZE_M __declspec(no_sanitize_address)
#else
#define NO_SANITIZE_M
#endif
class FAutoSeg class FAutoSeg
{ {
const char *name; const char *name;
@ -102,14 +108,14 @@ public:
} }
template <typename Func> template <typename Func>
void ForEach(Func func, std::enable_if_t<HasReturnTypeV<Func, void>> * = nullptr) void NO_SANITIZE_M ForEach(Func func, std::enable_if_t<HasReturnTypeV<Func, void>> * = nullptr)
{ {
using CallableType = decltype(&Func::operator()); using CallableType = decltype(&Func::operator());
using ArgType = typename ArgumentType<CallableType>::Type; using ArgType = typename ArgumentType<CallableType>::Type;
for (void **it = begin; it < end; ++it) for (void **it = begin; it < end; ++it)
{ {
if (*it) if (intptr_t(it) > 0xffff && *it && intptr_t(*it) > 0xffff)
{ {
func(reinterpret_cast<ArgType>(*it)); func(reinterpret_cast<ArgType>(*it));
} }
@ -117,14 +123,14 @@ public:
} }
template <typename Func> template <typename Func>
void ForEach(Func func, std::enable_if_t<HasReturnTypeV<Func, bool>> * = nullptr) void NO_SANITIZE_M ForEach(Func func, std::enable_if_t<HasReturnTypeV<Func, bool>> * = nullptr)
{ {
using CallableType = decltype(&Func::operator()); using CallableType = decltype(&Func::operator());
using ArgType = typename ArgumentType<CallableType>::Type; using ArgType = typename ArgumentType<CallableType>::Type;
for (void **it = begin; it < end; ++it) for (void **it = begin; it < end; ++it)
{ {
if (*it) if (intptr_t(it) > 0xffff && *it && intptr_t(*it) > 0xffff)
{ {
if (!func(reinterpret_cast<ArgType>(*it))) if (!func(reinterpret_cast<ArgType>(*it)))
{ {

View file

@ -187,7 +187,7 @@ bool PClass::ReadAllFields(FSerializer &ar, void *addr) const
// //
//========================================================================== //==========================================================================
static int cregcmp (const void *a, const void *b) NO_SANITIZE static NO_SANITIZE_M int cregcmp (const void *a, const void *b) NO_SANITIZE
{ {
const PClass *class1 = *(const PClass **)a; const PClass *class1 = *(const PClass **)a;
const PClass *class2 = *(const PClass **)b; const PClass *class2 = *(const PClass **)b;