Bug 1395805 - Diagnose VirtualAlloc failures draft
authorChih-Yi Leu <subsevenx2001@gmail.com>
Mon, 23 Oct 2017 16:10:00 +0800
changeset 684625 1190c4f5b9665d3d01ccf88de4eba55b28f674ce
parent 684511 ce1a86d3b4db161c95d1147676bbed839d7a4732
child 736922 87a35bca758708cf6f65f21e8dc2df851a2b9216
push id85679
push userbmo:cleu@mozilla.com
push dateMon, 23 Oct 2017 09:04:10 +0000
bugs1395805
milestone58.0a1
Bug 1395805 - Diagnose VirtualAlloc failures MozReview-Commit-ID: 9gz4qXM4vDk
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -1402,18 +1402,23 @@ pages_commit(void *addr, size_t size)
 	* The region starting at addr may have been allocated in multiple calls
 	* to VirtualAlloc and recycled, so committing the entire region in one
 	* go may not be valid. However, since we allocate at least a chunk at a
 	* time, we may touch any region in chunksized increments.
 	*/
 	size_t pages_size = std::min(size, chunksize -
 		CHUNK_ADDR2OFFSET((uintptr_t)addr));
 	while (size > 0) {
-		if (!VirtualAlloc(addr, pages_size, MEM_COMMIT, PAGE_READWRITE))
-			MOZ_CRASH();
+		if (!VirtualAlloc(addr, pages_size, MEM_COMMIT, PAGE_READWRITE)) {
+      fprintf(stderr,"@#@#@#@#@# - pages_commit failed!!\n");
+      fprintf(stderr,"@#@#@#@#@# - Address = %p\n",addr);
+      fprintf(stderr,"@#@#@#@#@# - Page Size Requested = %d\n",pages_size);
+      fprintf(stderr,"@#@#@#@#@# - Error Code = %X\n", GetLastError());
+      MOZ_CRASH();
+    }
 		addr = (void *)((uintptr_t)addr + pages_size);
 		size -= pages_size;
 		pages_size = std::min(size, chunksize);
 	}
 #  else
 	if (mmap(addr, size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE |
 	    MAP_ANON, -1, 0) == MAP_FAILED)
 		MOZ_CRASH();