From f31a3eb3290c4154bd04113c8bb859a499f288b6 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 1 Feb 2016 13:21:56 -0800 Subject: Binder: Add log output in IPCThreadState::self() In the failure case, and on shutdown, add log output. It's highly likely the client will crash when a null value is returned. Displaying a possible root cause helps diagnosing issues. Bug: 26865304 Change-Id: Ie5255ac50d6dcdf9f918dcef785788ea795a4791 --- libs/binder/IPCThreadState.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libs/binder/IPCThreadState.cpp') diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index a237684783..1f6bda2a94 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -287,12 +287,18 @@ restart: return new IPCThreadState; } - if (gShutdown) return NULL; + if (gShutdown) { + ALOGW("Calling IPCThreadState::self() during shutdown is dangerous, expect a crash.\n"); + return NULL; + } pthread_mutex_lock(&gTLSMutex); if (!gHaveTLS) { - if (pthread_key_create(&gTLS, threadDestructor) != 0) { + int key_create_value = pthread_key_create(&gTLS, threadDestructor); + if (key_create_value != 0) { pthread_mutex_unlock(&gTLSMutex); + ALOGW("IPCThreadState::self() unable to create TLS key, expect a crash: %s\n", + strerror(key_create_value)); return NULL; } gHaveTLS = true; -- cgit v1.2.3-59-g8ed1b