tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

stacktrace_windbg.rst (8744B)


      1 How to get a stacktrace with WinDbg
      2 ===================================
      3 
      4 +--------------------------------------------------------------------+
      5 | This page is an import from MDN and the contents might be outdated |
      6 +--------------------------------------------------------------------+
      7 
      8 Introduction
      9 ------------
     10 
     11 Sometimes you need to get a stacktrace (call stack) for a crash or hang
     12 but `Breakpad <http://kb.mozillazine.org/Breakpad>`__ fails because it's
     13 a special crash or a hang. This article describes how to get a
     14 stacktrace in those cases with WinDbg on Windows. (To get a stacktrace
     15 for Thunderbird or some other product, substitute the product name where
     16 ever you see Firefox in this instructions.)
     17 
     18 Requirements
     19 ------------
     20 
     21 To get such a stacktrace you need to install the following software:
     22 
     23 Debugging Tools for Windows
     24 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
     25 
     26 Microsoft distributes the Debugging Tools for Windows for free, those
     27 include WinDbg which you will need here. Download it from `Install
     28 Debugging Tools for
     29 Windows <https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk>`__.
     30 (*You'll want the 32-bit version*, even if you are using a 64-bit
     31 version of Windows) Then install it, the standard settings in the
     32 installation process are fine.
     33 
     34 A Firefox nightly or release
     35 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     36 
     37 You need a Firefox version for which symbols are availables from the
     38 :ref:`symbol server <Using The Mozilla Symbol Server>` to use
     39 with WinDbg. You can use any `official nightly
     40 build <https://ftp.mozilla.org/pub/firefox/nightly/>`__ or released
     41 version of Firefox from Mozilla. You can find the latest trunk nightly
     42 builds under
     43 `http://ftp.mozilla.org/pub/mozilla.o.../latest-trunk/ <https://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-central/>`__.
     44 
     45 
     46 Debugging
     47 ---------
     48 
     49 To begin debugging, ensure that Firefox is not already running and open
     50 WinDbg from the Start menu. (Start->All Programs->Debugging Tools for
     51 Windows->WinDbg) Next, open the **"File"** menu and choose **"Open
     52 Executable..."**. In the file chooser window that appears, open the
     53 firefox.exe executable in your Firefox program folder (C:\Program
     54 Files\Mozilla Firefox).
     55 
     56 You should now see a "Command" text window with debug output at the top
     57 and an input box at the bottom. Before debugging can start, several
     58 commands must be entered into the one-line input box at the bottom of
     59 the Command window.
     60 
     61 .. note::
     62 
     63   Tip: All commands must be entered exactly as written, one line at a
     64   time, into the bottom of the Command box.
     65 
     66   -  Copying and pasting each line is the easiest method to avoid
     67      mistakes
     68   -  Some commands start with a period (.) or a pipe character (|),
     69      which is required. (The keystroke for a pipe character on US
     70      keyboards is SHIFT+\)
     71   -  Submit the log file on a bug or via the support site, even if
     72      nothing seems to happen during the debug process
     73 
     74 
     75 Start debugging
     76 ~~~~~~~~~~~~~~~
     77 
     78 Now that Firefox is opened in the debugger, you need to configure your
     79 WinDbg to download symbols from the Mozilla symbol server. To load the
     80 symbols, enter the three commands below, pressing enter after each one.
     81 (More details are available at :ref:`symbol server <Using The Mozilla Symbol Server>`.)
     82 
     83 ::
     84 
     85   .sympath SRV*c:\symbols*http://symbols.mozilla.org/firefox;SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
     86   .symfix+ c:\symbols
     87   .reload /f
     88 
     89 Now wait for the symbols to download. This may take some time depending
     90 on your connection speed; the total size of the Mozilla and Microsoft
     91 symbols download is around 1.4GB. WinDbg will show "Busy" at the bottom
     92 of the application window until the download is complete.
     93 
     94 Once the download is complete, you need to configure WinDbg to examine
     95 child processes, ignore a specific event caused by Flash Player, and
     96 record a log of loaded modules. You will also want to open a log file to
     97 save data you collect. To do this, enter these four commands, pressing
     98 enter after each one.
     99 
    100 ::
    101 
    102   .logopen /t c:\temp\firefox-debug.log
    103   .childdbg 1
    104   .tlist
    105   sxn gp
    106   lm
    107 
    108 If you see firefox.exe listed in the output from .tlist more than once,
    109 then you are already running the application and need to close the
    110 running instance first before you start debugging, otherwise you won't
    111 get useful results.
    112 
    113 Now run Firefox by opening the **Debug** menu and clicking **Go**.
    114 **While Firefox is running, you will not be able to type any commands
    115 into the debugger.** After it starts, try to reproduce the crash or
    116 hanging issue that you are seeing.
    117 
    118 .. note::
    119 
    120   If Firefox fails to start, and you see lines of text followed by a
    121   command prompt in the debugger, a "breakpoint" may have been
    122   triggered. If you are prompted for a command but don't see an error
    123   about a crash, go back to the **Debug** menu and press **Go**.
    124 
    125 Once the browser crashes, you will see an error (such as "Access
    126 violation") in the WinDbg Command window. If Firefox hangs and there is
    127 no command prompt available in the debugger, open the **Debug** menu and
    128 choose **Break.** Once the browser has crashed or been stopped, continue
    129 with the steps below.
    130 
    131 
    132 After the crash or hang
    133 ~~~~~~~~~~~~~~~~~~~~~~~
    134 
    135 You need to capture the debug information to include in a bug comment or
    136 support request. Enter these three commands, one at a time, to get the
    137 stacktrace, crash/hang analysis and log of loaded modules. (Again, press
    138 Enter after each command.)
    139 
    140 ::
    141 
    142   ~* kp
    143   !analyze -v -f
    144   lm
    145 
    146 After these steps are completed, find the file
    147 **c:\temp\firefox-debug-(Today's Date).txt** on your hard drive. To
    148 provide the information to the development community, submit this file
    149 with a `support request <https://support.mozilla.com/>`__ or attach it
    150 to a related bug on `Bugzilla <https://bugzilla.mozilla.org/>`__.
    151 
    152 
    153 Producing a minidump
    154 ~~~~~~~~~~~~~~~~~~~~
    155 
    156 Sometimes the stacktrace alone is not enough information for a developer
    157 to figure out what went wrong. A developer may ask you for a "minidump"
    158 or a "full memory dump", which are files containing more information
    159 about the process. :ref:`You can easily produce minidumps from WinDBG and
    160 provide them to developers <Capturing a minidump>`.
    161 
    162 FAQ
    163 
    164 Q: I am running Windows 7 (32-bit or 64-bit) and I see an exception in
    165 the WinDbg command window that says 'ntdll32!LdrpDoDebuggerBreak+0x2c'
    166 or 'ntdll32!LdrpDoDebuggerBreak+0x30'. What do I do now?
    167 
    168 A: If you see 'int 3' after either of those exceptions, you will need to
    169 execute the following commands in WinDbg.
    170 
    171 ::
    172 
    173   bp ntdll!LdrpDoDebuggerBreak+0x30
    174   bp ntdll!LdrpDoDebuggerBreak+0x2c
    175   eb ntdll!LdrpDoDebuggerBreak+0x30 0x90
    176   eb ntdll!LdrpDoDebuggerBreak+0x2c 0x90
    177 
    178 | Make sure you enter them one at a time and press enter after each one.
    179  If you use the 64-bit version of Windows, you need to replace "ntdll"
    180  in these commands with "ntdll32".
    181 | Q: The first four frames of my stack trace look like this:
    182 
    183 ::
    184 
    185   0012fe20 7c90e89a ntdll!KiFastSystemCallRet
    186   0012fe24 7c81cd96 ntdll!ZwTerminateProcess+0xc
    187   0012ff20 7c81cdee kernel32!_ExitProcess+0x62
    188 
    189   0012ff34 6000179e kernel32!ExitProcess+0x14
    190 
    191 This looks wrong to me?!
    192 
    193 A: You ran the application without the "Debug child processes also"
    194 check box being checked. You need to detach the debugger and open the
    195 application again, this time with the check box being checked.
    196 
    197 Q: WinDbg tells me that it is unable to verify checksum for firefox.exe.
    198 Is this normal?
    199 
    200 A: Yes, this is normal and can be ignored.
    201 
    202 Q: Should I click yes or no when WinDbg asks me to "Save information for
    203 workspace?"
    204 
    205 A: Click yes and WinDbg will save you from having to enter in the symbol
    206 location for Firefox.exe in the future. Click no if you'd rather not
    207 having WinDbg save this information.
    208 
    209 Q: I'm seeing "wow64" on top of each thread, is that ok ?
    210 
    211 A: No, you are running a 64 bit version of Windbg and trying to debug a
    212 32 bit version of the mozilla software. Redownload and install the 32
    213 bit version of windbg.
    214 
    215 
    216 Troubleshooting: Symbols will not download
    217 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    218 
    219 If symbols will not download no matter what you do, the problem may be
    220 that Internet Explorer has been set to the **Work Offline** mode. You
    221 will not receive any warnings of this in Windbg, Visual C++ or Visual
    222 Studio. Even using the command line with symchk.exe to download symbols
    223 will fail. This is because Microsoft uses Internet Explorer's internet &
    224 proxy settings to download the symbol files. Check the File menu of
    225 Internet Explorer to ensure "Work Offline" is unchecked.
    226 
    227 
    228 See also
    229 --------
    230 
    231 -  :ref:`symbol server <Using The Mozilla Symbol Server>` Maps addresses to human readable strings.
    232 -  :ref:`source server <Using The Mozilla Source Server>` Maps addresses to source code lines