Skip to content

feat: Enable hang reporting via Crashpad for 3P#10770

Draft
hlwarriner wants to merge 1 commit into
youtube:mainfrom
hlwarriner:hw-3p
Draft

feat: Enable hang reporting via Crashpad for 3P#10770
hlwarriner wants to merge 1 commit into
youtube:mainfrom
hlwarriner:hw-3p

Conversation

@hlwarriner
Copy link
Copy Markdown
Contributor

@hlwarriner hlwarriner commented Jun 4, 2026

This PR is meant as a proof of concept but is really not too far from production ready code, so we may consider trying to land it.

There are a couple key differences vs. the approach used by 1P ATV:

  • The CrashHandler Starboard extension is used as a bridge to enable the hermetically built Cobalt layer to request that Crashpad generate a dump without crashing. This is required because the Crashpad client library is not linked into libcobalt. The Starboard extension is extended to provide this additional functionality.
  • Because Evergreen builds do not support the crash key system from Chromium, the CrashHandler Starboard extension is used to pass the critical list-of-hung-threads annotation from the Cobalt layer to the Crashpad handler.

#vibe-coded

Issue: 513671861

This PR is meant as a proof of concept but is really not too far from
production ready code, so we may consider trying to land it.

There are a couple key differences vs. the approach used by 1P ATV:
* The CrashHandler Starboard extension is used as a bridge to enable the
  hermetically built Cobalt layer to request that Crashpad generate a
  dump without crashing. This is required because the Crashpad client
  library is not linked into libcobalt. The Starboard extension is
  extended to provide this additional functionality.
* Because Evergreen builds do not support the crash key system from
  Chromium, the CrashHandler Starboard extension is used to pass the
  critical list-of-hung-threads annotation from the Cobalt layer to the
  Crashpad handler.

Issue: 513671861
@hlwarriner hlwarriner requested review from a team as code owners June 4, 2026 20:13
@hlwarriner hlwarriner requested a review from johnxwork June 4, 2026 20:13
@hlwarriner hlwarriner marked this pull request as draft June 4, 2026 20:13
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🤖 Gemini Suggested Commit Message


starboard: Enable hang reporting via Crashpad

Evergreen builds do not link the Crashpad client library into the
hermetic libcobalt library. To enable hang reporting on these
platforms, the CrashHandler Starboard extension is used as a bridge
for Cobalt to request that Crashpad generate a dump without crashing.

The Starboard extension is updated to version 4 to include support
for DumpWithoutCrashing and passing hung thread annotations. This
allows the Cobalt layer to communicate critical hang information, such
as the list of hung threads, to the Crashpad handler on third-party
platforms where the library is not directly accessible.

Issue: 513671861

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for triggering non-crashing dump reports (DumpWithoutCrashing) on Starboard/Evergreen builds by extending the CobaltExtensionCrashHandlerApi and integrating it with the HangWatcher and Crashpad wrapper. Feedback on the changes includes: updating the DumpWithoutCrashing extension API signature to return bool to prevent compilation errors with Chromium's SetDumpWithoutCrashingFunction; adding a null check for SetString in hang_watcher.cc to prevent potential crashes; and invoking the g_dump_without_crashing_callback outside of the mutex lock in crash_handler.cc to avoid potential deadlocks during dump generation.

Comment on lines +65 to +66
// Triggers a non-crashing dump/hang report.
void (*DumpWithoutCrashing)();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The DumpWithoutCrashing function pointer is currently defined to return void. However, base::debug::SetDumpWithoutCrashingFunction in Chromium's base/debug/dump_without_crashing.h expects a function pointer with the signature bool (*)(). Passing a void (*)() function pointer directly will result in a compilation error. Updating the extension API signature to return bool (indicating whether the dump was successfully triggered) resolves this type mismatch cleanly.

Suggested change
// Triggers a non-crashing dump/hang report.
void (*DumpWithoutCrashing)();
// Triggers a non-crashing dump/hang report.
// Returns true if the dump request was successfully triggered.
bool (*DumpWithoutCrashing)();
References
  1. Adhere to the established upstream Chromium style guides for C++ as specified in the repository style guide. (link)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems incorrect.

From https://github.com/youtube/cobalt/blob/main/base/debug/dump_without_crashing.h#L54:

BASE_EXPORT void SetDumpWithoutCrashingFunction(void (*function)());

Comment on lines +1098 to +1105
auto* crash_handler_extension =
static_cast<const CobaltExtensionCrashHandlerApi*>(
SbSystemGetExtension(kCobaltExtensionCrashHandlerName));
if (crash_handler_extension && crash_handler_extension->version >= 2) {
crash_handler_extension->SetString("list-of-hung-threads",
list_of_hung_thread_ids.c_str());
// TODO: b/513671861 - Cobalt: consider adding support for other crash keys.
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The SetString function pointer is called without checking if it is null. To prevent potential crashes if an implementation of the extension has a null SetString pointer, please add a null check for crash_handler_extension->SetString before calling it.

  auto* crash_handler_extension =
      static_cast<const CobaltExtensionCrashHandlerApi*>(
          SbSystemGetExtension(kCobaltExtensionCrashHandlerName));
  if (crash_handler_extension && crash_handler_extension->version >= 2 &&
      crash_handler_extension->SetString) {
    crash_handler_extension->SetString("list-of-hung-threads",
                                       list_of_hung_thread_ids.c_str());
    // TODO: b/513671861 - Cobalt: consider adding support for other crash keys.
  }
References
  1. Adhere to the established upstream Chromium style guides for C++ as specified in the repository style guide. (link)

Comment on lines +57 to +63
void DumpWithoutCrashing() {
SB_CHECK_EQ(pthread_mutex_lock(&g_dump_without_crashing_callback_mutex), 0);
if (g_dump_without_crashing_callback) {
g_dump_without_crashing_callback();
}
SB_CHECK_EQ(pthread_mutex_unlock(&g_dump_without_crashing_callback_mutex), 0);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Invoking the callback g_dump_without_crashing_callback while holding g_dump_without_crashing_callback_mutex can lead to deadlocks or block other threads unnecessarily, especially since generating a minidump can be a slow operation. It is safer to copy the callback pointer under the lock, release the lock, and then invoke the callback. Additionally, updating this function to return bool aligns with the updated signature of DumpWithoutCrashing in the extension API.

bool DumpWithoutCrashing() {
  void (*callback)() = nullptr;
  SB_CHECK_EQ(pthread_mutex_lock(&g_dump_without_crashing_callback_mutex), 0);
  callback = g_dump_without_crashing_callback;
  SB_CHECK_EQ(pthread_mutex_unlock(&g_dump_without_crashing_callback_mutex), 0);

  if (callback) {
    callback();
    return true;
  }
  return false;
}
References
  1. Adhere to the established upstream Chromium style guides for C++ as specified in the repository style guide. (link)

@hlwarriner hlwarriner removed the request for review from johnxwork June 4, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant