summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Erhardt <github@sicherha.de>2022-02-22 21:29:14 +0100
committerChristoph Erhardt <christoph.erhardt@sicherha.de>2022-02-22 21:30:23 +0100
commit096b9015dc52f6dd35e923f1624e1862a1d1fa25 (patch)
tree0a9ed0b9f3d9cfb21204fb701c27b2ce30e0dcfc
parent817569dfad79732233fb86649c89e04387ce02e9 (diff)
Fix compatibility with GNU libstdc++ < 9
So far, mimalloc does not override the `nothrow` variants of the `delete` operator because it assumes that their implementation in the C++ standard library redirects to the default `delete` operators. This is not the case for GNU libstdc++ < 9, where `std::free()` is called directly. This issue might be the cause for the crashes reported in #261. Upstream bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68210 This commit ensures that the `nothrow` `delete` operators are properly overridden by mimalloc.
-rw-r--r--include/mimalloc-new-delete.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/mimalloc-new-delete.h b/include/mimalloc-new-delete.h
index ba208f0..9714977 100644
--- a/include/mimalloc-new-delete.h
+++ b/include/mimalloc-new-delete.h
@@ -25,6 +25,9 @@ terms of the MIT license. A copy of the license can be found in the file
void operator delete(void* p) noexcept { mi_free(p); };
void operator delete[](void* p) noexcept { mi_free(p); };
+ void operator delete (void* p, const std::nothrow_t&) noexcept { mi_free(p); }
+ void operator delete[](void* p, const std::nothrow_t&) noexcept { mi_free(p); }
+
void* operator new(std::size_t n) noexcept(false) { return mi_new(n); }
void* operator new[](std::size_t n) noexcept(false) { return mi_new(n); }