You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在gdb中调试Chrome子进程崩溃(Aw-Snap页面)并获取栈追踪?

Debugging Chrome's "Aw, Snap!" Crashes with GDB

Let me walk you through how to fix this issue—Chrome’s multi-process architecture is the main culprit here, and we need to adjust both GDB settings and Chrome’s launch flags to capture those renderer crashes properly.

Why Your Current Setup Isn’t Working

Chrome spins up separate processes for tabs (renderers), GPU, plugins, etc. By default, GDB detaches from child processes after a fork(), which is why you lose track when the browser starts up. Setting detach-on-fork off breaks Chrome’s process management because it expects child processes to detach cleanly, hence the failed launch.

Solution 1: Tune GDB to Track Child Processes (With Sandbox Disabled)

This method keeps GDB attached to all child processes and switches focus to them when they crash:

  1. Launch GDB with your Chrome binary (adjust the path if needed):
    gdb /usr/bin/google-chrome
    
  2. Inside GDB, set these critical debugging options:
    # Don't detach from child processes after fork
    set detach-on-fork off
    # Switch GDB's focus to the child process when fork happens
    set follow-fork-mode child
    # Notify when new threads/processes are created
    set print thread-events on
    
  3. Start Chrome with sandbox disabled (sandbox blocks debugger access to child processes):
    run --no-sandbox
    
    When a tab crashes (shows "Aw, Snap!"), GDB will halt at the crash point. Run bt full to get a complete stack trace.

Solution 2: Attach GDB Directly to Renderer Processes

If you only care about renderer crashes, this approach makes Chrome launch each renderer inside GDB automatically:
Run Chrome with this command (again, disable sandbox for debugging):

google-chrome --renderer-cmd-prefix="gdb -ex 'handle SIGSEGV stop print pass' -ex 'run' -ex 'bt full' -ex 'quit' --args" --no-sandbox

Every time a renderer process crashes, GDB will print the full stack trace to your terminal before exiting.

Key Notes

  • Always use --no-sandbox for debugging: Chrome’s sandbox prevents debuggers from accessing child processes, so this flag is non-negotiable for capturing crashes.
  • Install debug symbols: If your stack traces only show memory addresses instead of function names, install Chrome’s debug symbols package (e.g., google-chrome-dbg on Debian/Ubuntu).
  • Disable GPU if needed: Add --disable-gpu to rule out GPU process interference if crashes are inconsistent.

内容的提问来源于stack exchange,提问作者kenorb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:02:45