fix: change gin_wrappable to scoped crash key (#30578)

This commit is contained in:
Keeley Hammond 2021-08-18 13:51:40 -07:00 коммит произвёл GitHub
Родитель 8699124397
Коммит cbeae20438
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 13 добавлений и 8 удалений

Просмотреть файл

@ -15,28 +15,32 @@ This patch should not be upstreamed, and can be removed in Electron 15 and
beyond once we identify the cause of the crash. beyond once we identify the cause of the crash.
diff --git a/gin/wrappable.cc b/gin/wrappable.cc diff --git a/gin/wrappable.cc b/gin/wrappable.cc
index fe07eb94a8e679859bba6d76ff0d6ee86bd0c67e..d0066fca501eae5be4177440b44dbecc8e34c897 100644 index fe07eb94a8e679859bba6d76ff0d6ee86bd0c67e..ecb0aa2c4ec57e1814f4c94194e775440f4e35ee 100644
--- a/gin/wrappable.cc --- a/gin/wrappable.cc
+++ b/gin/wrappable.cc +++ b/gin/wrappable.cc
@@ -8,6 +8,10 @@ @@ -8,6 +8,11 @@
#include "gin/object_template_builder.h" #include "gin/object_template_builder.h"
#include "gin/per_isolate_data.h" #include "gin/per_isolate_data.h"
+#if !defined(MAS_BUILD) +#if !defined(MAS_BUILD)
+#include "components/crash/core/common/crash_key.h"
+#include "electron/shell/common/crash_keys.h" +#include "electron/shell/common/crash_keys.h"
+#endif +#endif
+ +
namespace gin { namespace gin {
WrappableBase::WrappableBase() = default; WrappableBase::WrappableBase() = default;
@@ -36,6 +40,12 @@ void WrappableBase::FirstWeakCallback( @@ -36,6 +41,15 @@ void WrappableBase::FirstWeakCallback(
void WrappableBase::SecondWeakCallback( void WrappableBase::SecondWeakCallback(
const v8::WeakCallbackInfo<WrappableBase>& data) { const v8::WeakCallbackInfo<WrappableBase>& data) {
WrappableBase* wrappable = data.GetParameter(); WrappableBase* wrappable = data.GetParameter();
+ +
+#if !defined(MAS_BUILD) +#if !defined(MAS_BUILD)
+ WrapperInfo* info = static_cast<WrapperInfo*>(data.GetInternalField(0)); + WrapperInfo* wrapperInfo = static_cast<WrapperInfo*>(data.GetInternalField(0));
+ electron::crash_keys::SetCrashKeyForGinWrappable(info); + std::string location = electron::crash_keys::GetCrashValueForGinWrappable(wrapperInfo);
+
+ static crash_reporter::CrashKeyString<32> crash_key("gin-wrappable-fatal.location");
+ crash_reporter::ScopedCrashKeyString auto_clear(&crash_key, location);
+#endif +#endif
+ +
delete wrappable; delete wrappable;

Просмотреть файл

@ -185,7 +185,7 @@ void SetPlatformCrashKey() {
#endif #endif
} }
void SetCrashKeyForGinWrappable(gin::WrapperInfo* info) { std::string GetCrashValueForGinWrappable(gin::WrapperInfo* info) {
std::string crash_location; std::string crash_location;
// Adds a breadcrumb for crashes within gin::WrappableBase::SecondWeakCallback // Adds a breadcrumb for crashes within gin::WrappableBase::SecondWeakCallback
@ -254,7 +254,7 @@ void SetCrashKeyForGinWrappable(gin::WrapperInfo* info) {
"Deleted kWrapperInfo does not match listed component. Please review " "Deleted kWrapperInfo does not match listed component. Please review "
"listed crash keys."; "listed crash keys.";
SetCrashKey("gin-wrappable-fatal.location", crash_location); return crash_location;
} }
} // namespace crash_keys } // namespace crash_keys

Просмотреть файл

@ -24,7 +24,8 @@ void GetCrashKeys(std::map<std::string, std::string>* keys);
void SetCrashKeysFromCommandLine(const base::CommandLine& command_line); void SetCrashKeysFromCommandLine(const base::CommandLine& command_line);
void SetPlatformCrashKey(); void SetPlatformCrashKey();
void SetCrashKeyForGinWrappable(gin::WrapperInfo* info);
std::string GetCrashValueForGinWrappable(gin::WrapperInfo* info);
} // namespace crash_keys } // namespace crash_keys