aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2015-12-08 18:14:44 -0800
committerTodd Poynor <toddpoynor@google.com>2015-12-09 13:32:37 -0800
commitf615c101fabdc7fee026a77acb04d0598ec837c2 (patch)
tree44b78b131e0f79353441631b6550be78f5deaa24
parent65b6811c638d0a94a14f301be8840c500c28b025 (diff)
downloadmetricsd-f615c101fabdc7fee026a77acb04d0598ec837c2.tar.gz
metricsd binder: Abort if fail to register service
Assert abort metricsd if binder service registration fails. If the addService() call fails (for reasons that at least include an SELinux policy denial), the call to joinThreadPool() apparently processes a stale pending weak dereference that triggers an abort on a probable double-free: F libc : Invalid address 0xbe8bfa30 passed to free: value not allocated F libc : Fatal signal 6 (SIGABRT), code -6 in tid 609 (metricsd) Since metricsd is severely hobbled if registration fails, abort and see if things work better the next time. If not, the crash loop will hopefully attract attention to the problem. Change-Id: I520d0eafb9cb25ee225d589bfd87df4e51f6b181
-rw-r--r--uploader/bn_metricsd_impl.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/uploader/bn_metricsd_impl.cc b/uploader/bn_metricsd_impl.cc
index 113a705..2cbc2da 100644
--- a/uploader/bn_metricsd_impl.cc
+++ b/uploader/bn_metricsd_impl.cc
@@ -21,6 +21,7 @@
#include <base/metrics/statistics_recorder.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
+#include <utils/Errors.h>
#include <utils/String16.h>
#include <utils/String8.h>
@@ -33,11 +34,14 @@ static const char16_t kCrashTypeUser[] = u"user";
BnMetricsdImpl::BnMetricsdImpl(const std::shared_ptr<CrashCounters>& counters)
: counters_(counters) {
- CHECK(counters_);
+ CHECK(counters_) << "Invalid counters argument to constructor";
}
void BnMetricsdImpl::Run() {
- android::defaultServiceManager()->addService(getInterfaceDescriptor(), this);
+ android::status_t status =
+ android::defaultServiceManager()->addService(getInterfaceDescriptor(),
+ this);
+ CHECK(status == android::OK) << "Metricsd service registration failed";
android::ProcessState::self()->setThreadPoolMaxThreadCount(0);
android::IPCThreadState::self()->disableBackgroundScheduling(true);
android::IPCThreadState::self()->joinThreadPool();