From 1eefca281ee837d183e49951ae29683d8665129a Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Thu, 1 Sep 2016 07:28:44 -0700 Subject: [PATCH 1/2] logd: crash in prune mLastWorstPidOfSystem mLastWorstPidOfSystem is supposed to be indexed by element->getPid() Bug: 31237377 Bug: 30797725 Bug: 30688716 Change-Id: I81a55e92f175ded1c571a0aa8836736d86b36b1d --- logd/LogBuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index fa957332d..0b195a6f5 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp @@ -678,7 +678,7 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { && ((!gc && (element->getPid() == worstPid)) || (mLastWorstPidOfSystem[id].find(element->getPid()) == mLastWorstPidOfSystem[id].end()))) { - mLastWorstPidOfSystem[id][key] = it; + mLastWorstPidOfSystem[id][element->getPid()] = it; } if ((!gc && !worstPid && (key == worst)) || (mLastWorst[id].find(key) == mLastWorst[id].end())) { From 43a5f31e94513d4412ad1f552fd35d04e480a658 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Thu, 1 Sep 2016 15:48:36 -0700 Subject: [PATCH 2/2] logd: clear all from non system user status request pruneRows not necessarily ULONG_MAX when uid not system source, allow for speed up for status response if pruneRows exhausted. Change-Id: I38c76bb20215e3d96513a575e2e3bc85a5e5b41c --- logd/LogBuffer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index 0b195a6f5..1ecf99c98 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp @@ -508,7 +508,8 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { LogBufferElementCollection::iterator it; if (caller_uid != AID_ROOT) { - // Only here if clearAll condition (pruneRows == ULONG_MAX) + // Only here if clear all request from non system source, so chatty + // filter logistics is not required. it = mLastSet[id] ? mLast[id] : mLogElements.begin(); while (it != mLogElements.end()) { LogBufferElement *element = *it; @@ -534,7 +535,9 @@ bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) { } it = erase(it); - pruneRows--; + if (--pruneRows == 0) { + break; + } } LogTimeEntry::unlock(); return busy;