summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-10-29 10:59:09 -0700
committerSteve Kondik <shade@chemlab.org>2013-11-22 05:35:41 -0800
commitcde2aab4c557ec0c847375424658ccc2188b36ce (patch)
tree9d4cb897ac916b746d5b1661b8f52bc748442b40
parent48704eccc23e91f3ee46ea4882d1dfef43646cc4 (diff)
downloadandroid_dalvik-stable/cm-10.2.tar.gz
android_dalvik-stable/cm-10.2.tar.bz2
android_dalvik-stable/cm-10.2.zip
Fix a couple of minor publicly-reported GC bugs.cm-10.2.1cm-10.2.0stable/cm-10.2cm-10.2
An assertion was incorrectly assigning rather than testing, and there was the usual buggy attempt to recover from failure rather than just aborting in the HeapSource.cpp dvmHeapSourceStartup. (The Copying.cpp dvmHeapSourceStartup by contrast will just segfault if an allocation fails, but that's fine too.) Bug: https://code.google.com/p/android/issues/detail?id=61562 Bug: https://code.google.com/p/android/issues/detail?id=61563 Change-Id: I237a6f923a07d61709f99ab67c9a18dbc7e6c839
-rw-r--r--vm/alloc/Copying.cpp2
-rw-r--r--vm/alloc/HeapSource.cpp25
2 files changed, 11 insertions, 16 deletions
diff --git a/vm/alloc/Copying.cpp b/vm/alloc/Copying.cpp
index 77cdac33c..195670eb1 100644
--- a/vm/alloc/Copying.cpp
+++ b/vm/alloc/Copying.cpp
@@ -461,7 +461,7 @@ GcHeap *dvmHeapSourceStartup(size_t startSize, size_t absoluteMaxSize)
heapSource->allocBlocks = 0;
heapSource->totalBlocks = (heapSource->limitBlock - heapSource->baseBlock);
- assert(heapSource->totalBlocks = heapSource->maximumSize / BLOCK_SIZE);
+ assert(heapSource->totalBlocks == heapSource->maximumSize / BLOCK_SIZE);
{
size_t size = sizeof(heapSource->blockQueue[0]);
diff --git a/vm/alloc/HeapSource.cpp b/vm/alloc/HeapSource.cpp
index d1f10845d..3e5238a65 100644
--- a/vm/alloc/HeapSource.cpp
+++ b/vm/alloc/HeapSource.cpp
@@ -572,8 +572,8 @@ static void freeMarkStack(GcMarkStack *stack)
GcHeap* dvmHeapSourceStartup(size_t startSize, size_t maximumSize,
size_t growthLimit)
{
- GcHeap *gcHeap;
- HeapSource *hs;
+ GcHeap *gcHeap = NULL;
+ HeapSource *hs = NULL;
mspace msp;
size_t length;
void *base;
@@ -593,7 +593,7 @@ GcHeap* dvmHeapSourceStartup(size_t startSize, size_t maximumSize,
length = ALIGN_UP_TO_PAGE_SIZE(maximumSize);
base = dvmAllocRegion(length, PROT_NONE, "dalvik-heap");
if (base == NULL) {
- return NULL;
+ dvmAbort();
}
/* Create an unlocked dlmalloc mspace to use as
@@ -601,20 +601,19 @@ GcHeap* dvmHeapSourceStartup(size_t startSize, size_t maximumSize,
*/
msp = createMspace(base, kInitialMorecoreStart, startSize);
if (msp == NULL) {
- goto fail;
+ dvmAbort();
}
gcHeap = (GcHeap *)calloc(1, sizeof(*gcHeap));
if (gcHeap == NULL) {
LOGE_HEAP("Can't allocate heap descriptor");
- goto fail;
+ dvmAbort();
}
hs = (HeapSource *)calloc(1, sizeof(*hs));
if (hs == NULL) {
LOGE_HEAP("Can't allocate heap source");
- free(gcHeap);
- goto fail;
+ dvmAbort();
}
hs->targetUtilization = gDvm.heapTargetUtilization * HEAP_UTILIZATION_MAX;
@@ -642,32 +641,28 @@ GcHeap* dvmHeapSourceStartup(size_t startSize, size_t maximumSize,
if (!addInitialHeap(hs, msp, growthLimit)) {
LOGE_HEAP("Can't add initial heap");
- goto fail;
+ dvmAbort();
}
if (!dvmHeapBitmapInit(&hs->liveBits, base, length, "dalvik-bitmap-1")) {
LOGE_HEAP("Can't create liveBits");
- goto fail;
+ dvmAbort();
}
if (!dvmHeapBitmapInit(&hs->markBits, base, length, "dalvik-bitmap-2")) {
LOGE_HEAP("Can't create markBits");
dvmHeapBitmapDelete(&hs->liveBits);
- goto fail;
+ dvmAbort();
}
if (!allocMarkStack(&gcHeap->markContext.stack, hs->maximumSize)) {
ALOGE("Can't create markStack");
dvmHeapBitmapDelete(&hs->markBits);
dvmHeapBitmapDelete(&hs->liveBits);
- goto fail;
+ dvmAbort();
}
gcHeap->markContext.bitmap = &hs->markBits;
gcHeap->heapSource = hs;
gHs = hs;
return gcHeap;
-
-fail:
- munmap(base, length);
- return NULL;
}
bool dvmHeapSourceStartupAfterZygote()