Skip to content

Commit

Permalink
Merge r180430 - bmalloc should implement malloc introspection (to sto…
Browse files Browse the repository at this point in the history
…p false-positive leaks when MallocStackLogging is off)

https://bugs.webkit.org/show_bug.cgi?id=141802

Reviewed by Andreas Kling.

Rolling back in with a fix for a crash seen while using GuardMalloc.

* bmalloc/VMHeap.cpp:
(bmalloc::VMHeap::grow):
* bmalloc/VMHeap.h:
* bmalloc/Zone.cpp: Re-land the old patch.

(bmalloc::Zone::size): Be sure to implement the size() function since
it's accessible indirectly via the malloc_zone_from_ptr public API --
and GuardMalloc calls it all the time.

(bmalloc::Zone::Zone):
* bmalloc/Zone.h: Re-land the old patch.
  • Loading branch information
geoffreygaren authored and carlosgcampos committed Feb 27, 2015
1 parent 7380486 commit 7576502
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
36 changes: 36 additions & 0 deletions Source/bmalloc/ChangeLog
@@ -1,3 +1,39 @@
2015-02-20 Geoffrey Garen <ggaren@apple.com>

bmalloc should implement malloc introspection (to stop false-positive leaks when MallocStackLogging is off)
https://bugs.webkit.org/show_bug.cgi?id=141802

Reviewed by Andreas Kling.

Rolling back in with a fix for a crash seen while using GuardMalloc.

* bmalloc/VMHeap.cpp:
(bmalloc::VMHeap::grow):
* bmalloc/VMHeap.h:
* bmalloc/Zone.cpp: Re-land the old patch.

(bmalloc::Zone::size): Be sure to implement the size() function since
it's accessible indirectly via the malloc_zone_from_ptr public API --
and GuardMalloc calls it all the time.

(bmalloc::Zone::Zone):
* bmalloc/Zone.h: Re-land the old patch.

2015-02-19 Commit Queue <commit-queue@webkit.org>

Unreviewed, rolling out r180363.
https://bugs.webkit.org/show_bug.cgi?id=141814

Caused >50 crashes when running LayoutTests in GuardMalloc or
ASAN modes. (Requested by jernoble on #webkit).

Reverted changeset:

"bmalloc should implement malloc introspection (to stop false-
positive leaks when MallocStackLogging is off)"
https://bugs.webkit.org/show_bug.cgi?id=141802
http://trac.webkit.org/changeset/180363

2015-02-19 Geoffrey Garen <ggaren@apple.com>

bmalloc should implement malloc introspection (to stop false-positive leaks when MallocStackLogging is off)
Expand Down
14 changes: 11 additions & 3 deletions Source/bmalloc/bmalloc/Zone.cpp
Expand Up @@ -42,6 +42,13 @@ template<typename T> static void remoteRead(task_t task, memory_reader_t reader,
memcpy(&result, tmp, sizeof(T));
}

// Support malloc_zone_from_ptr, which calls size() on each registered zone.
size_t Zone::size(malloc_zone_t*, const void*)
{
// Our zone is not public API, so no pointer can belong to us.
return 0;
}

// This function runs inside the leaks process.
kern_return_t Zone::enumerator(task_t task, void* context, unsigned type_mask, vm_address_t zone_address, memory_reader_t reader, vm_range_recorder_t recorder)
{
Expand All @@ -63,9 +70,10 @@ kern_return_t Zone::enumerator(task_t task, void* context, unsigned type_mask, v

Zone::Zone()
{
version = 4;
zone_name = "WebKit Malloc";
introspect = &bmalloc::introspect;
malloc_zone_t::size = size;
malloc_zone_t::zone_name = "WebKit Malloc";
malloc_zone_t::introspect = &bmalloc::introspect;
malloc_zone_t::version = 4;
malloc_zone_register(this);
}

Expand Down
1 change: 1 addition & 0 deletions Source/bmalloc/bmalloc/Zone.h
Expand Up @@ -38,6 +38,7 @@ class Zone : public malloc_zone_t {
// Enough capacity to track a 64GB heap, so probably enough for anything.
static const size_t capacity = 2048;

static size_t size(malloc_zone_t*, const void*);
static kern_return_t enumerator(task_t, void* context, unsigned type_mask, vm_address_t, memory_reader_t, vm_range_recorder_t);

Zone();
Expand Down

0 comments on commit 7576502

Please sign in to comment.