[PATCH] Fix for size_t in Asan's new and delete operators on x64 FreeBSD in 32-bit mode
Viktor Kutuzov
vkutuzov at accesssoftek.com
Fri Feb 21 05:29:04 PST 2014
Hi kcc, samsonov,
http://llvm-reviews.chandlerc.com/D2856
Files:
lib/asan/asan_new_delete.cc
Index: lib/asan/asan_new_delete.cc
===================================================================
--- lib/asan/asan_new_delete.cc
+++ lib/asan/asan_new_delete.cc
@@ -49,15 +49,25 @@
// To make sure that C++ allocation/deallocation operators are overridden on
// OS X we need to intercept them using their mangled names.
#if !SANITIZER_MAC
+namespace __asan {
+// System headers define 'size_t' incorrectly on x64 FreeBSD when
+// compiled in 32-bit mode.
+#if SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 32
+typedef unsigned xsize_t;
+#else
+typedef size_t xsize_t;
+#endif
+} // namespace __asan
+
INTERCEPTOR_ATTRIBUTE
-void *operator new(size_t size) { OPERATOR_NEW_BODY(FROM_NEW); }
+void *operator new(xsize_t size) { OPERATOR_NEW_BODY(FROM_NEW); }
INTERCEPTOR_ATTRIBUTE
-void *operator new[](size_t size) { OPERATOR_NEW_BODY(FROM_NEW_BR); }
+void *operator new[](xsize_t size) { OPERATOR_NEW_BODY(FROM_NEW_BR); }
INTERCEPTOR_ATTRIBUTE
-void *operator new(size_t size, std::nothrow_t const&)
+void *operator new(xsize_t size, std::nothrow_t const&)
{ OPERATOR_NEW_BODY(FROM_NEW); }
INTERCEPTOR_ATTRIBUTE
-void *operator new[](size_t size, std::nothrow_t const&)
+void *operator new[](xsize_t size, std::nothrow_t const&)
{ OPERATOR_NEW_BODY(FROM_NEW_BR); }
#else // SANITIZER_MAC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2856.1.patch
Type: text/x-patch
Size: 1303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140221/087df5c5/attachment.bin>
More information about the llvm-commits
mailing list