summaryrefslogtreecommitdiffstats
path: root/vm/alloc
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-10-29 10:59:09 -0700
committerElliott Hughes <enh@google.com>2013-10-29 10:59:09 -0700
commit783b88d7028a38b2b1cd9e62498f6830e8d5b55e (patch)
tree6884e8d831f9b9e0bf1bfa9b00a7e1b87edb806a /vm/alloc
parent5931c4945defce8654aca9265f281155553ff557 (diff)
downloadandroid_dalvik-783b88d7028a38b2b1cd9e62498f6830e8d5b55e.tar.gz
android_dalvik-783b88d7028a38b2b1cd9e62498f6830e8d5b55e.tar.bz2
android_dalvik-783b88d7028a38b2b1cd9e62498f6830e8d5b55e.zip
Fix a couple of minor publicly-reported GC bugs.
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
Diffstat (limited to 'vm/alloc')
-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 93cdd2fd7..35e11c7f6 100644
--- a/vm/alloc/HeapSource.cpp
+++ b/vm/alloc/HeapSource.cpp
@@ -549,8 +549,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;
@@ -570,7 +570,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
@@ -578,20 +578,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;
@@ -619,32 +618,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()