diff --git a/src/ll/api/Expected.cpp b/src/ll/api/Expected.cpp index 2d00d67cc5..c678826c50 100644 --- a/src/ll/api/Expected.cpp +++ b/src/ll/api/Expected.cpp @@ -15,7 +15,7 @@ struct ErrorInfoBase::Impl { Stacktrace stacktrace; }; ErrorInfoBase::ErrorInfoBase() noexcept : impl(std::make_unique(Stacktrace::current(1))) {} -std::string Error::message() const noexcept { +std::string Error::message() const noexcept try { if (!mInfo) { return "success"; } @@ -23,6 +23,8 @@ std::string Error::message() const noexcept { res += "\nexpected stacktrace:\n"; res += stacktrace_utils::toString(mInfo->impl->stacktrace); return res; +} catch (...) { + return "unknown"; } struct ExceptionError : ErrorInfoBase { @@ -43,7 +45,9 @@ struct ExceptionError : ErrorInfoBase { #else struct ErrorInfoBase::Impl {}; ErrorInfoBase::ErrorInfoBase() noexcept {} -std::string Error::message() const noexcept { return mInfo ? mInfo->message() : "success"; } +std::string Error::message() const noexcept try { return mInfo ? mInfo->message() : "success"; } catch (...) { + return "unknown"; +} struct ExceptionError : ErrorInfoBase { std::exception_ptr exc; diff --git a/src/ll/core/tweak/MemoryOperators_win.cpp b/src/ll/core/tweak/MemoryOperators_win.cpp index 9895b4a28a..a3f4ade4f5 100644 --- a/src/ll/core/tweak/MemoryOperators_win.cpp +++ b/src/ll/core/tweak/MemoryOperators_win.cpp @@ -39,17 +39,25 @@ namespace ll::memory { } class MimallocMemoryAllocator : public ::Bedrock::Memory::IMemoryAllocator { public: - virtual void* allocate(uint64 size) { return mi_malloc(size != 0 ? size : 1); } + virtual void* allocate(uint64 size) try { return mi_malloc(size != 0 ? size : 1); } catch (...) { + return nullptr; + } - virtual void release(void* ptr) { mi_free(ptr); } + virtual void release(void* ptr) try { mi_free(ptr); } catch (...) { + } - virtual void* alignedAllocate(uint64 size, uint64 alignment) { + virtual void* alignedAllocate(uint64 size, uint64 alignment) try { return mi_malloc_aligned(size != 0 ? size : 1, alignment); + } catch (...) { + return nullptr; } - virtual void alignedRelease(void* ptr) { mi_free(ptr); } + virtual void alignedRelease(void* ptr) try { mi_free(ptr); } catch (...) { + } - virtual uint64 getUsableSize(void* ptr) { return mi_usable_size(ptr); } + virtual uint64 getUsableSize(void* ptr) try { return mi_usable_size(ptr); } catch (...) { + return 0; + } static void miOutput(char const* msg, void* /*arg*/) { std::string str{msg}; @@ -62,9 +70,14 @@ class MimallocMemoryAllocator : public ::Bedrock::Memory::IMemoryAllocator { getLogger().info(str); } - virtual void logCurrentState() { mi_stats_print_out(miOutput, nullptr); } + virtual void logCurrentState() try { mi_stats_print_out(miOutput, nullptr); } catch (...) { + } - virtual void* _realloc(gsl::not_null ptr, uint64 newSize) { return mi_realloc(ptr, newSize); } + virtual void* _realloc(gsl::not_null ptr, uint64 newSize) try { + return mi_realloc(ptr, newSize); + } catch (...) { + return nullptr; + } }; #ifdef LL_MEMORY_DEBUG