Skip to content

Commit c845614

Browse files
committed
Allow duplicate attachments for cloned/nested scopes
1 parent 69d7bdb commit c845614

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

handler/linux/crash_report_exception_handler.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,17 @@ bool CrashReportExceptionHandler::HandleExceptionWithConnection(
212212

213213
void CrashReportExceptionHandler::AddAttachment(
214214
const base::FilePath& attachment) {
215-
auto it = std::find(attachments_.begin(), attachments_.end(), attachment);
216-
if (it != attachments_.end()) {
217-
LOG(WARNING) << "ignoring duplicate attachment " << attachment;
218-
return;
219-
}
220215
attachments_.push_back(attachment);
221216
}
222217

223218
void CrashReportExceptionHandler::RemoveAttachment(
224219
const base::FilePath& attachment) {
225-
auto it = std::find(attachments_.begin(), attachments_.end(), attachment);
226-
if (it == attachments_.end()) {
227-
LOG(WARNING) << "ignoring non-existent attachment " << attachment;
220+
auto it = std::find(attachments_.rbegin(), attachments_.rend(), attachment);
221+
if (it == attachments_.rend()) {
222+
LOG(WARNING) << "no such attachment " << attachment;
228223
return;
229224
}
230-
attachments_.erase(it);
225+
attachments_.erase(std::next(it).base());
231226
}
232227

233228
bool CrashReportExceptionHandler::WriteMinidumpToDatabase(
@@ -272,7 +267,12 @@ bool CrashReportExceptionHandler::WriteMinidumpToDatabase(
272267
}
273268
}
274269

270+
std::set<base::FilePath> added_attachments;
275271
for (const auto& attachment : attachments_) {
272+
if (!added_attachments.insert(attachment).second) {
273+
continue;
274+
}
275+
276276
FileReader file_reader;
277277
if (!file_reader.Open(attachment)) {
278278
LOG(ERROR) << "attachment " << attachment.value().c_str()

handler/win/crash_report_exception_handler.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ unsigned int CrashReportExceptionHandler::ExceptionHandlerServerException(
115115
return termination_code;
116116
}
117117

118+
std::set<base::FilePath> added_attachments;
118119
for (const auto& attachment : attachments_) {
120+
if (!added_attachments.insert(attachment).second) {
121+
continue;
122+
}
123+
119124
FileReader file_reader;
120125
if (!file_reader.Open(attachment)) {
121126
LOG(ERROR) << "attachment " << attachment
@@ -170,22 +175,17 @@ unsigned int CrashReportExceptionHandler::ExceptionHandlerServerException(
170175

171176
void CrashReportExceptionHandler::ExceptionHandlerServerAttachmentAdded(
172177
const base::FilePath& attachment) {
173-
auto it = std::find(attachments_.begin(), attachments_.end(), attachment);
174-
if (it != attachments_.end()) {
175-
LOG(WARNING) << "ignoring duplicate attachment " << attachment;
176-
return;
177-
}
178178
attachments_.push_back(attachment);
179179
}
180180

181181
void CrashReportExceptionHandler::ExceptionHandlerServerAttachmentRemoved(
182182
const base::FilePath& attachment) {
183-
auto it = std::find(attachments_.begin(), attachments_.end(), attachment);
184-
if (it == attachments_.end()) {
185-
LOG(WARNING) << "ignoring non-existent attachment " << attachment;
183+
auto it = std::find(attachments_.rbegin(), attachments_.rend(), attachment);
184+
if (it == attachments_.rend()) {
185+
LOG(WARNING) << "no such attachment " << attachment;
186186
return;
187187
}
188-
attachments_.erase(it);
188+
attachments_.erase(std::next(it).base());
189189
}
190190

191191
} // namespace crashpad

0 commit comments

Comments
 (0)