Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1501)

Unified Diff: third_party/tcmalloc/vendor/src/malloc_hook.cc

Issue 9701040: Revert 126715 - Update the tcmalloc vendor branch to r144 (gperftools 2.0). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/vendor/src/malloc_hook.cc
===================================================================
--- third_party/tcmalloc/vendor/src/malloc_hook.cc (revision 126727)
+++ third_party/tcmalloc/vendor/src/malloc_hook.cc (working copy)
@@ -46,11 +46,12 @@
#include <stdint.h>
#endif
#include <algorithm>
+#include "base/basictypes.h"
#include "base/logging.h"
#include "base/spinlock.h"
#include "maybe_threads.h"
#include "malloc_hook-inl.h"
-#include <gperftools/malloc_hook.h>
+#include <google/malloc_hook.h>
// This #ifdef should almost never be set. Set NO_TCMALLOC_SAMPLES if
// you're porting to a system where you really can't get a stacktrace.
@@ -58,7 +59,7 @@
// We use #define so code compiles even if you #include stacktrace.h somehow.
# define GetStackTrace(stack, depth, skip) (0)
#else
-# include <gperftools/stacktrace.h>
+# include <google/stacktrace.h>
#endif
// __THROW is defined in glibc systems. It means, counter-intuitively,
@@ -203,8 +204,14 @@
template <typename T>
bool HookList<T>::Add(T value_as_t) {
- AtomicWord value = bit_cast<AtomicWord>(value_as_t);
+ // Note: we need to check this _before_ reinterpret_cast, since
+ // reinterpret_cast may include random junk from memory.
+ if (value_as_t == 0) {
+ return false;
+ }
+ AtomicWord value = reinterpret_cast<const AtomicWord&>(value_as_t);
if (value == 0) {
+ // This should not actually happen, but just to be sure...
return false;
}
SpinLockHolder l(&hooklist_spinlock);
@@ -233,7 +240,8 @@
SpinLockHolder l(&hooklist_spinlock);
AtomicWord hooks_end = base::subtle::Acquire_Load(&priv_end);
int index = 0;
- while (index < hooks_end && value_as_t != bit_cast<T>(
+ // Note: we need to cast back to T since T may be smaller than AtomicWord.
+ while (index < hooks_end && value_as_t != reinterpret_cast<T>(
base::subtle::Acquire_Load(&priv_data[index]))) {
++index;
}
@@ -260,7 +268,7 @@
for (int i = 0; i < hooks_end && n > 0; ++i) {
AtomicWord data = base::subtle::Acquire_Load(&priv_data[i]);
if (data != 0) {
- *output_array++ = bit_cast<T>(data);
+ *output_array++ = reinterpret_cast<const T&>(data);
++actual_hooks_end;
--n;
}
@@ -697,7 +705,9 @@
#if defined(__linux)
# include "malloc_hook_mmap_linux.h"
-#elif defined(__FreeBSD__)
+// This code doesn't even compile on my freebsd 8.1 (x86_64) system,
+// so comment it out for now. TODO(csilvers): fix this!
+#elif 0 && defined(__FreeBSD__)
# include "malloc_hook_mmap_freebsd.h"
#else
« no previous file with comments | « third_party/tcmalloc/vendor/src/malloc_extension.cc ('k') | third_party/tcmalloc/vendor/src/malloc_hook-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698