[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
Sat Feb 22 03:10:52 PST 2014


  The comment updated so that it refers to the FreeBSD fix.

  > The _types.h issue is fixed in FreeBSD 10, as of r232261

  Thanks Ed! There are a few other issues with bulding and running 32-bit executables on x64 FreeBSD that prevent some sanitizers' tests from performing correctly. I will file more defects on freebsd.org so if you can address them in meantime, that'd be great. Thanks again.

Hi kcc, samsonov,

http://llvm-reviews.chandlerc.com/D2856

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2856?vs=7285&id=7299#toc

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 {
+// System headers define 'size_t' incorrectly on x64 FreeBSD (prior to
+// FreeBSD 10, r232261) when compiled in 32-bit mode.
+#if SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 32
+typedef unsigned xsize_t;
+#else
+typedef size_t xsize_t;
+#endif
+}  // namespace
+
 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.3.patch
Type: text/x-patch
Size: 1320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140222/2b9ea86c/attachment.bin>


More information about the llvm-commits mailing list