summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorsenorblanco@google.com <senorblanco@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-22 20:31:04 +0000
committersenorblanco@google.com <senorblanco@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-22 20:31:04 +0000
commit54fe91778e4ed5d5a8a513c6883ae40a2a7c1f6f (patch)
tree047a657d2f58305193149a9fc4889d17879fc294 /skia
parent1c6c13e755ae44861cf9acfc5613f7dee837b3f5 (diff)
downloadchromium_src-54fe91778e4ed5d5a8a513c6883ae40a2a7c1f6f.zip
chromium_src-54fe91778e4ed5d5a8a513c6883ae40a2a7c1f6f.tar.gz
chromium_src-54fe91778e4ed5d5a8a513c6883ae40a2a7c1f6f.tar.bz2
Fix for Skia data race. This may introduce some performance issues; will watch perf bots carefully.
BUG=46672 TEST=see perf bits Review URL: http://codereview.chromium.org/2876001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50510 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/SkMemory_new_handler.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/skia/ext/SkMemory_new_handler.cpp b/skia/ext/SkMemory_new_handler.cpp
index e64de61..06bc2c9 100644
--- a/skia/ext/SkMemory_new_handler.cpp
+++ b/skia/ext/SkMemory_new_handler.cpp
@@ -7,12 +7,15 @@
#include <new>
#include "third_party/skia/include/core/SkTypes.h"
+#include "third_party/skia/include/core/SkThread.h"
// This implementation of sk_malloc_flags() and friends is identical
// to SkMemory_malloc.c, except that it disables the CRT's new_handler
// during malloc(), when SK_MALLOC_THROW is not set (ie., when
// sk_malloc_flags() would not abort on NULL).
+static SkMutex gSkNewHandlerMutex;
+
void sk_throw() {
SkASSERT(!"sk_throw");
abort();
@@ -45,13 +48,14 @@ void sk_free(void* p) {
}
void* sk_malloc_flags(size_t size, unsigned flags) {
- std::new_handler old_handler;
- if (!(flags & SK_MALLOC_THROW)) {
- old_handler = std::set_new_handler(NULL);
- }
- void* p = malloc(size);
+ void* p;
if (!(flags & SK_MALLOC_THROW)) {
+ SkAutoMutexAcquire lock(gSkNewHandlerMutex);
+ std::new_handler old_handler = std::set_new_handler(NULL);
+ p = malloc(size);
std::set_new_handler(old_handler);
+ } else {
+ p = malloc(size);
}
if (p == NULL) {
if (flags & SK_MALLOC_THROW) {