From d930308bbbfa089a63df67c4f78065604494d39d Mon Sep 17 00:00:00 2001 From: John Z Wu Date: Mon, 13 May 2019 12:49:43 -0700 Subject: Fix orphaned crash reports. The path NSCachesDirectory may change across app updates and sometimes even across app launches. As a result, the Config-XXX files may end up with an outdated path to the associated minidump file. Change-Id: I0befde26b2ac406c154ce7c7e9be0063ee99892d Bug:850379 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1592561 Reviewed-by: Mark Mentovai --- src/client/ios/Breakpad.mm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/client/ios/Breakpad.mm') diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm index 2d8ba61e..2b61bbe3 100644 --- a/src/client/ios/Breakpad.mm +++ b/src/client/ios/Breakpad.mm @@ -161,6 +161,7 @@ class Breakpad { NSArray *CrashReportsToUpload(); NSString *NextCrashReportToUpload(); NSDictionary *NextCrashReportConfiguration(); + NSDictionary *FixedUpCrashReportConfiguration(NSDictionary *configuration); NSDate *DateOfMostRecentCrashReport(); void UploadNextReport(NSDictionary *server_parameters); void UploadReportWithConfiguration(NSDictionary *configuration, @@ -466,7 +467,18 @@ NSString *Breakpad::NextCrashReportToUpload() { //============================================================================= NSDictionary *Breakpad::NextCrashReportConfiguration() { - return [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()]; + NSDictionary *configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()]; + return FixedUpCrashReportConfiguration(configuration); +} + +//============================================================================= +NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configuration) { + NSMutableDictionary *fixedConfiguration = [[configuration mutableCopy] autorelease]; + // kReporterMinidumpDirectoryKey can become stale because the app's data container path includes + // an UUID that is not guaranteed to stay the same over time. + [fixedConfiguration setObject:KeyValue(@BREAKPAD_DUMP_DIRECTORY) + forKey:@kReporterMinidumpDirectoryKey]; + return fixedConfiguration; } //============================================================================= -- cgit v1.2.1