Commit 6056c0dc authored by Irina Yatsenko's avatar Irina Yatsenko Committed by Commit Bot

Make adding crash keys thread safe

Bug: chromium:977893
Change-Id: Ibd4be9b9ce13bcb8aca4b6ac6d7a1c56a01e39d9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1676606Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Irina Yatsenko <irinayat@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#62392}
parent b2d47f24
......@@ -33,7 +33,9 @@ static CrashKeyInstance crash_keys[] = {
};
void AddCrashKey(int id, const char* name, uintptr_t value) {
static int current = 0;
static std::atomic<int> last{-1};
const int current = ++last;
if (current > kMaxCrashKeysCount) {
return;
}
......@@ -41,7 +43,6 @@ void AddCrashKey(int id, const char* name, uintptr_t value) {
if (current == kMaxCrashKeysCount) {
static crash_reporter::CrashKeyString<1> over("v8-too-many-keys");
over.Set("1");
current++;
return;
}
......@@ -50,8 +51,6 @@ void AddCrashKey(int id, const char* name, uintptr_t value) {
std::stringstream stream;
stream << name << " " << id << " 0x" << std::hex << value;
trace_key.Set(stream.str().substr(0, kKeySize));
current++;
}
} // namespace crash
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment