Modified: trunk/Source/bmalloc/ChangeLog (187359 => 187360)
--- trunk/Source/bmalloc/ChangeLog 2015-07-24 20:41:25 UTC (rev 187359)
+++ trunk/Source/bmalloc/ChangeLog 2015-07-24 21:03:09 UTC (rev 187360)
@@ -1,3 +1,23 @@
+2015-07-24 Geoffrey Garen <[email protected]>
+
+ _javascript_Core bmalloc should not register its malloc zone more than once
+ https://bugs.webkit.org/show_bug.cgi?id=147273
+
+ Reviewed by Andreas Kling.
+
+ This was a goof: The Zone constructor, by virtue of running automatically,
+ was registering a Zone inside the analysis process.
+
+ * bmalloc/Zone.cpp:
+ (bmalloc::remoteRead): Clarify that the pointer is remote.
+
+ (bmalloc::enumerator):
+ (bmalloc::Zone::Zone):
+ * bmalloc/Zone.h: Separate the normal constructor and the remote constructor.
+ The remote constructor skips zone registration since its goal is not
+ to register a zone in the current process or do any allocation but rather
+ to mirror the bytes of the zone from the target process.
+
2015-07-23 Geoffrey Garen <[email protected]>
bmalloc: Shrink the super chunk size (again)
Modified: trunk/Source/bmalloc/bmalloc/Zone.cpp (187359 => 187360)
--- trunk/Source/bmalloc/bmalloc/Zone.cpp 2015-07-24 20:41:25 UTC (rev 187359)
+++ trunk/Source/bmalloc/bmalloc/Zone.cpp 2015-07-24 21:03:09 UTC (rev 187360)
@@ -28,10 +28,10 @@
namespace bmalloc {
-template<typename T> static void remoteRead(task_t task, memory_reader_t reader, vm_address_t pointer, T& result)
+template<typename T> static void remoteRead(task_t task, memory_reader_t reader, vm_address_t remotePointer, T& result)
{
void* tmp;
- (*reader)(task, pointer, sizeof(T), &tmp);
+ (*reader)(task, remotePointer, sizeof(T), &tmp);
memcpy(&result, tmp, sizeof(T));
}
@@ -79,9 +79,7 @@
// This function runs inside the leaks process.
static kern_return_t enumerator(task_t task, void* context, unsigned type_mask, vm_address_t zone_address, memory_reader_t reader, vm_range_recorder_t recorder)
{
- Zone remoteZone;
- remoteRead(task, reader, zone_address, remoteZone);
-
+ Zone remoteZone(task, reader, zone_address);
for (auto* superChunk : remoteZone.superChunks()) {
vm_range_t range = { reinterpret_cast<vm_address_t>(superChunk), superChunkSize };
@@ -118,4 +116,9 @@
malloc_zone_register(this);
}
+Zone::Zone(task_t task, memory_reader_t reader, vm_address_t remotePointer)
+{
+ remoteRead(task, reader, remotePointer, *this);
+}
+
} // namespace bmalloc
Modified: trunk/Source/bmalloc/bmalloc/Zone.h (187359 => 187360)
--- trunk/Source/bmalloc/bmalloc/Zone.h 2015-07-24 20:41:25 UTC (rev 187359)
+++ trunk/Source/bmalloc/bmalloc/Zone.h 2015-07-24 21:03:09 UTC (rev 187360)
@@ -39,6 +39,7 @@
static const size_t capacity = 2048;
Zone();
+ Zone(task_t, memory_reader_t, vm_address_t);
void addSuperChunk(SuperChunk*);
FixedVector<SuperChunk*, capacity>& superChunks() { return m_superChunks; }