for (int i = 0; i < numViolations; ++i) {
if (LOG_V) Log.d(TAG, "strict mode violation stacks read from binder call. i=" + i);
ViolationInfo info = new ViolationInfo(p, !currentlyGathering);
- if (info.crashInfo.stackTrace.length() > 5000) {
- RuntimeException here = new RuntimeException("here");
- here.fillInStackTrace();
- Slog.w(TAG, "Stack is getting large: " + info.crashInfo.stackTrace, here);
+ if (info.crashInfo.stackTrace.length() > 10000) {
+ // 10000 characters is way too large for this to be any sane kind of
+ // strict mode collection of stacks. We've had a problem where we leave
+ // strict mode violations associated with the thread, and it keeps tacking
+ // more and more stacks on to the violations. Looks like we're in this casse,
+ // so we'll report it and bail on all of the current strict mode violations
+ // we currently are maintaining for this thread.
+ // First, drain the remaining violations from the parcel.
+ while (i < numViolations) {
+ info = new ViolationInfo(p, !currentlyGathering);
+ i++;
+ }
+ // Next clear out all gathered violations.
+ clearGatheredViolations();
+ // Now report the problem.
+ Slog.wtfStack(TAG, "Stack is too large: numViolations=" + numViolations
+ + " policy=#" + Integer.toHexString(policyMask)
+ + " front=" + info.crashInfo.stackTrace.substring(256));
+ return;
}
info.crashInfo.stackTrace += "# via Binder call with stack:\n" + ourStack;
BlockGuard.Policy policy = BlockGuard.getThreadPolicy();
msg + '\n' + Log.getStackTraceString(tr));
}
+ /**
+ * Like {@link Log#wtf(String, String)}, but will never cause the caller to crash, and
+ * will always be handled asynchronously. Primarily for use by coding running within
+ * the system process.
+ */
public static int wtf(String tag, String msg) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true);
}
+ /**
+ * Like {@link Log#wtfStack(String, String)}, but will never cause the caller to crash, and
+ * will always be handled asynchronously. Primarily for use by coding running within
+ * the system process.
+ */
public static int wtfStack(String tag, String msg) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true, true);
}
+ /**
+ * Like {@link Log#wtf(String, Throwable)}, but will never cause the caller to crash,
+ * and will always be handled asynchronously. Primarily for use by coding running within
+ * the system process.
+ */
public static int wtf(String tag, Throwable tr) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false, true);
}
+ /**
+ * Like {@link Log#wtf(String, String, Throwable)}, but will never cause the caller to crash,
+ * and will always be handled asynchronously. Primarily for use by coding running within
+ * the system process.
+ */
public static int wtf(String tag, String msg, Throwable tr) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false, true);
}
}
public void onEvent(int event, String path) {
- int modsInFlight = sKnownMutationsInFlight.get(mUserHandle).get();
- if (modsInFlight > 0) {
+ final AtomicInteger mutationCount;
+ synchronized (SettingsProvider.this) {
+ mutationCount = sKnownMutationsInFlight.get(mUserHandle);
+ }
+ if (mutationCount != null && mutationCount.get() > 0) {
// our own modification.
return;
}
checkWritePermissions(args);
SettingsCache cache = cacheForTable(callingUser, args.table);
- final AtomicInteger mutationCount = sKnownMutationsInFlight.get(callingUser);
- mutationCount.incrementAndGet();
+ final AtomicInteger mutationCount;
+ synchronized (this) {
+ mutationCount = sKnownMutationsInFlight.get(callingUser);
+ }
+ if (mutationCount != null) {
+ mutationCount.incrementAndGet();
+ }
DatabaseHelper dbH = getOrEstablishDatabase(
TABLE_GLOBAL.equals(args.table) ? UserHandle.USER_OWNER : callingUser);
SQLiteDatabase db = dbH.getWritableDatabase();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
- mutationCount.decrementAndGet();
+ if (mutationCount != null) {
+ mutationCount.decrementAndGet();
+ }
}
sendNotify(uri, callingUser);
return Uri.withAppendedPath(url, name);
}
- final AtomicInteger mutationCount = sKnownMutationsInFlight.get(desiredUserHandle);
- mutationCount.incrementAndGet();
+ final AtomicInteger mutationCount;
+ synchronized (this) {
+ mutationCount = sKnownMutationsInFlight.get(callingUser);
+ }
+ if (mutationCount != null) {
+ mutationCount.incrementAndGet();
+ }
DatabaseHelper dbH = getOrEstablishDatabase(desiredUserHandle);
SQLiteDatabase db = dbH.getWritableDatabase();
final long rowId = db.insert(args.table, null, initialValues);
- mutationCount.decrementAndGet();
+ if (mutationCount != null) {
+ mutationCount.decrementAndGet();
+ }
if (rowId <= 0) return null;
SettingsCache.populate(cache, initialValues); // before we notify
}
checkWritePermissions(args);
- final AtomicInteger mutationCount = sKnownMutationsInFlight.get(callingUser);
- mutationCount.incrementAndGet();
+ final AtomicInteger mutationCount;
+ synchronized (this) {
+ mutationCount = sKnownMutationsInFlight.get(callingUser);
+ }
+ if (mutationCount != null) {
+ mutationCount.incrementAndGet();
+ }
DatabaseHelper dbH = getOrEstablishDatabase(callingUser);
SQLiteDatabase db = dbH.getWritableDatabase();
int count = db.delete(args.table, args.where, args.args);
- mutationCount.decrementAndGet();
+ if (mutationCount != null) {
+ mutationCount.decrementAndGet();
+ }
if (count > 0) {
invalidateCache(callingUser, args.table); // before we notify
sendNotify(url, callingUser);
checkWritePermissions(args);
checkUserRestrictions(initialValues.getAsString(Settings.Secure.NAME), callingUser);
- final AtomicInteger mutationCount = sKnownMutationsInFlight.get(callingUser);
- mutationCount.incrementAndGet();
+ final AtomicInteger mutationCount;
+ synchronized (this) {
+ mutationCount = sKnownMutationsInFlight.get(callingUser);
+ }
+ if (mutationCount != null) {
+ mutationCount.incrementAndGet();
+ }
DatabaseHelper dbH = getOrEstablishDatabase(callingUser);
SQLiteDatabase db = dbH.getWritableDatabase();
int count = db.update(args.table, initialValues, args.where, args.args);
- mutationCount.decrementAndGet();
+ if (mutationCount != null) {
+ mutationCount.decrementAndGet();
+ }
if (count > 0) {
invalidateCache(callingUser, args.table); // before we notify
sendNotify(url, callingUser);
import static com.android.internal.util.XmlUtils.writeIntAttribute;
import static com.android.internal.util.XmlUtils.writeLongAttribute;
import static com.android.server.Watchdog.NATIVE_STACKS_OF_INTEREST;
-import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;
}
}
} catch (InterruptedException e) {
- Log.wtf(TAG, e);
+ Slog.wtf(TAG, e);
}
}
observer.wait(200); // Wait for write-close, give up after 200msec
}
} catch (InterruptedException e) {
- Log.wtf(TAG, e);
+ Slog.wtf(TAG, e);
}
}
} catch (FileNotFoundException e) {
// Missing grants is okay
} catch (IOException e) {
- Log.wtf(TAG, "Failed reading Uri grants", e);
+ Slog.wtf(TAG, "Failed reading Uri grants", e);
} catch (XmlPullParserException e) {
- Log.wtf(TAG, "Failed reading Uri grants", e);
+ Slog.wtf(TAG, "Failed reading Uri grants", e);
} finally {
IoUtils.closeQuietly(fis);
}
* @param crashInfo describing the context of the error
* @return true if the process should exit immediately (WTF is fatal)
*/
- public boolean handleApplicationWtf(IBinder app, final String tag, boolean system,
+ public boolean handleApplicationWtf(final IBinder app, final String tag, boolean system,
final ApplicationErrorReport.CrashInfo crashInfo) {
- final ProcessRecord r = findAppProcess(app, "WTF");
- final String processName = app == null ? "system_server"
- : (r == null ? "unknown" : r.processName);
-
- EventLog.writeEvent(EventLogTags.AM_WTF,
- UserHandle.getUserId(Binder.getCallingUid()), Binder.getCallingPid(),
- processName,
- r == null ? -1 : r.info.flags,
- tag, crashInfo.exceptionMessage);
+ final int callingUid = Binder.getCallingUid();
+ final int callingPid = Binder.getCallingPid();
if (system) {
// If this is coming from the system, we could very well have low-level
// never want this to become fatal, so there is that too.
mHandler.post(new Runnable() {
@Override public void run() {
- addErrorToDropBox("wtf", r, processName, null, null, tag, null, null,
- crashInfo);
+ handleApplicationWtfInner(callingUid, callingPid, app, tag, crashInfo);
}
});
return false;
}
- addErrorToDropBox("wtf", r, processName, null, null, tag, null, null, crashInfo);
+ final ProcessRecord r = handleApplicationWtfInner(callingUid, callingPid, app, tag,
+ crashInfo);
if (r != null && r.pid != Process.myPid() &&
Settings.Global.getInt(mContext.getContentResolver(),
}
}
+ ProcessRecord handleApplicationWtfInner(int callingUid, int callingPid, IBinder app, String tag,
+ final ApplicationErrorReport.CrashInfo crashInfo) {
+ final ProcessRecord r = findAppProcess(app, "WTF");
+ final String processName = app == null ? "system_server"
+ : (r == null ? "unknown" : r.processName);
+
+ EventLog.writeEvent(EventLogTags.AM_WTF, UserHandle.getUserId(callingUid), callingPid,
+ processName, r == null ? -1 : r.info.flags, tag, crashInfo.exceptionMessage);
+
+ addErrorToDropBox("wtf", r, processName, null, null, tag, null, null, crashInfo);
+
+ return r;
+ }
+
/**
* @param app object of some object (as stored in {@link com.android.internal.os.RuntimeInit})
* @return the corresponding {@link ProcessRecord} object, or null if none could be found
Slog.w(TAG, "Exception when sending broadcast to "
+ r.curComponent, e);
} catch (RuntimeException e) {
- Log.wtf(TAG, "Failed sending broadcast to "
+ Slog.wtf(TAG, "Failed sending broadcast to "
+ r.curComponent + " with " + r.intent, e);
// If some unexpected exception happened, just skip
// this broadcast. At this point we are not in the call
*/
void removeReadOwner(UriPermissionOwner owner) {
if (!mReadOwners.remove(owner)) {
- Log.wtf(TAG, "Unknown read owner " + owner + " in " + this);
+ Slog.wtf(TAG, "Unknown read owner " + owner + " in " + this);
}
if (mReadOwners.size() == 0) {
mReadOwners = null;
*/
void removeWriteOwner(UriPermissionOwner owner) {
if (!mWriteOwners.remove(owner)) {
- Log.wtf(TAG, "Unknown write owner " + owner + " in " + this);
+ Slog.wtf(TAG, "Unknown write owner " + owner + " in " + this);
}
if (mWriteOwners.size() == 0) {
mWriteOwners = null;
mWifiDisplayAdapter.requestStopScanLocked();
}
} else if (mWifiDisplayScanRequestCount < 0) {
- Log.wtf(TAG, "mWifiDisplayScanRequestCount became negative: "
+ Slog.wtf(TAG, "mWifiDisplayScanRequestCount became negative: "
+ mWifiDisplayScanRequestCount);
mWifiDisplayScanRequestCount = 0;
}
} catch (FileNotFoundException e) {
// Missing sessions are okay, probably first boot
} catch (IOException e) {
- Log.wtf(TAG, "Failed reading install sessions", e);
+ Slog.wtf(TAG, "Failed reading install sessions", e);
} catch (XmlPullParserException e) {
- Log.wtf(TAG, "Failed reading install sessions", e);
+ Slog.wtf(TAG, "Failed reading install sessions", e);
} finally {
IoUtils.closeQuietly(fis);
}
mReadMessages.append("Error reading: " + e.toString());
PackageManagerService.reportSettingsProblem(Log.ERROR,
"Error reading stopped packages: " + e);
- Log.wtf(PackageManagerService.TAG, "Error reading package manager stopped packages", e);
+ Slog.wtf(PackageManagerService.TAG, "Error reading package manager stopped packages",
+ e);
} catch (java.io.IOException e) {
mReadMessages.append("Error reading: " + e.toString());
PackageManagerService.reportSettingsProblem(Log.ERROR, "Error reading settings: " + e);
- Log.wtf(PackageManagerService.TAG, "Error reading package manager stopped packages", e);
+ Slog.wtf(PackageManagerService.TAG, "Error reading package manager stopped packages",
+ e);
}
}
// might have been corrupted.
if (!backupFile.exists()) {
if (!userPackagesStateFile.renameTo(backupFile)) {
- Log.wtf(PackageManagerService.TAG, "Unable to backup user packages state file, "
+ Slog.wtf(PackageManagerService.TAG,
+ "Unable to backup user packages state file, "
+ "current changes will be lost at reboot");
return;
}
// Done, all is good!
return;
} catch(java.io.IOException e) {
- Log.wtf(PackageManagerService.TAG,
+ Slog.wtf(PackageManagerService.TAG,
"Unable to write package manager user packages state, "
+ " current changes will be lost at reboot", e);
}
mReadMessages.append("Error reading: " + e.toString());
PackageManagerService.reportSettingsProblem(Log.ERROR,
"Error reading stopped packages: " + e);
- Log.wtf(PackageManagerService.TAG, "Error reading package manager stopped packages", e);
+ Slog.wtf(PackageManagerService.TAG, "Error reading package manager stopped packages",
+ e);
} catch (java.io.IOException e) {
mReadMessages.append("Error reading: " + e.toString());
PackageManagerService.reportSettingsProblem(Log.ERROR, "Error reading settings: " + e);
- Log.wtf(PackageManagerService.TAG, "Error reading package manager stopped packages", e);
+ Slog.wtf(PackageManagerService.TAG, "Error reading package manager stopped packages",
+ e);
}
}
// might have been corrupted.
if (!mBackupSettingsFilename.exists()) {
if (!mSettingsFilename.renameTo(mBackupSettingsFilename)) {
- Log.wtf(PackageManagerService.TAG, "Unable to backup package manager settings, "
+ Slog.wtf(PackageManagerService.TAG,
+ "Unable to backup package manager settings, "
+ " current changes will be lost at reboot");
return;
}
str.close();
journal.commit();
} catch (Exception e) {
- Log.wtf(TAG, "Failed to write packages.list", e);
+ Slog.wtf(TAG, "Failed to write packages.list", e);
IoUtils.closeQuietly(str);
journal.rollback();
}
return;
} catch(XmlPullParserException e) {
- Log.wtf(PackageManagerService.TAG, "Unable to write package manager settings, "
+ Slog.wtf(PackageManagerService.TAG, "Unable to write package manager settings, "
+ "current changes will be lost at reboot", e);
} catch(java.io.IOException e) {
- Log.wtf(PackageManagerService.TAG, "Unable to write package manager settings, "
+ Slog.wtf(PackageManagerService.TAG, "Unable to write package manager settings, "
+ "current changes will be lost at reboot", e);
}
// Clean up partially written files
if (mSettingsFilename.exists()) {
if (!mSettingsFilename.delete()) {
- Log.wtf(PackageManagerService.TAG, "Failed to clean up mangled file: "
+ Slog.wtf(PackageManagerService.TAG, "Failed to clean up mangled file: "
+ mSettingsFilename);
}
}
mReadMessages.append("No start tag found in settings file\n");
PackageManagerService.reportSettingsProblem(Log.WARN,
"No start tag found in package manager settings");
- Log.wtf(PackageManagerService.TAG,
+ Slog.wtf(PackageManagerService.TAG,
"No start tag found in package manager settings");
return false;
}
} catch (XmlPullParserException e) {
mReadMessages.append("Error reading: " + e.toString());
PackageManagerService.reportSettingsProblem(Log.ERROR, "Error reading settings: " + e);
- Log.wtf(PackageManagerService.TAG, "Error reading package manager settings", e);
+ Slog.wtf(PackageManagerService.TAG, "Error reading package manager settings", e);
} catch (java.io.IOException e) {
mReadMessages.append("Error reading: " + e.toString());
PackageManagerService.reportSettingsProblem(Log.ERROR, "Error reading settings: " + e);
- Log.wtf(PackageManagerService.TAG, "Error reading package manager settings", e);
+ Slog.wtf(PackageManagerService.TAG, "Error reading package manager settings", e);
}
final int N = mPendingPackages.size();
t.start();
t.join();
} catch (InterruptedException e) {
- Log.wtf(TAG, e);
+ Slog.wtf(TAG, e);
}
}
mService.mWatermark.drawIfNeeded();
}
} catch (RuntimeException e) {
- Log.wtf(TAG, "Unhandled exception in Window Manager", e);
+ Slog.wtf(TAG, "Unhandled exception in Window Manager", e);
} finally {
SurfaceControl.closeTransaction();
if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(
}
}
} catch (RuntimeException e) {
- Log.wtf(TAG, "Unhandled exception while force removing for memory", e);
+ Slog.wtf(TAG, "Unhandled exception while force removing for memory", e);
}
try {
}
} catch (RuntimeException e) {
mInLayout = false;
- Log.wtf(TAG, "Unhandled exception while laying out windows", e);
+ Slog.wtf(TAG, "Unhandled exception while laying out windows", e);
}
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
mDisplayManagerInternal.performTraversalInTransactionFromWindowManager();
} catch (RuntimeException e) {
- Log.wtf(TAG, "Unhandled exception in Window Manager", e);
+ Slog.wtf(TAG, "Unhandled exception in Window Manager", e);
} finally {
SurfaceControl.closeTransaction();
if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
private void reportWtf(String msg, Throwable e) {
Slog.w(TAG, "***********************************************");
- Log.wtf(TAG, "BOOT FAILURE " + msg, e);
+ Slog.wtf(TAG, "BOOT FAILURE " + msg, e);
}
private void performPendingShutdown() {