Debugging crashing Xfce apps isn’t terribly difficult, and can be a big help to Xfce developers when they’re trying to fix bugs. If the problem you’re having is a crash of a particular application, usually you’ll want to get what’s called a ‘backtrace’ or ‘stack trace’ using a debugger, such as gdb.
What should I do first?
First, check the Xfce bug tracker. Maybe someone has already seen this problem and done all the work for you. Or maybe they’ve seen the problem, but haven’t provided any useful information yet. If that’s the case, perhaps you could help out and add to their bug report.
Next, be sure you can reproduce the problem. If you can’t, it’s going to be hard to get debug information.
You’ll need a debugger. The one I use most frequently is called gdb, and should be available on pretty much any distribution/OS where you can run Xfce.
What caused the crash?
The next task is to determine what’s crashing. Here are some ways to determine what’s going on:
- All of Xfce (or X) crashed.
- In this case, it’s possible that Xfce was not at fault. Check the messages printed to console. If it was actually X itself that crashed, you’ll want to report that elsewhere.
- If, however, Xfce is at fault, it’s likely a crash in xfce4-session. Debugging xfce4-session is a little bit more involved than other apps, since it’s what’s known as the ‘session controlling app’. More about this later.
- The borders around all my windows disappeared, and all my minimised windows are shown.
- This is likely a crash in xfwm4. Since focusing particular windows is difficult without a window manager, debugging xfwm4 can be a little annoying. More about this later, as well.
- The panel/app launcher/toolbar or taskbar disappeared.
- One of the plugins/applets in my panel disappeared, but the panel is still running.
- The panel is OK here, but one of its ‘external’ plugins crashed.
- The desktop background and/or icons disappeared. I also can’t access the desktop’s right-click or middle-click menus.
- I’m not sure that anything crashed, but my user interface theme went back to this ugly default, as did my fonts and icons.
- It’s possible that xfce-mcs-manager has crashed.
- Some other thing happened. Application X was running, and disappeared from the screen.
- Unfortunately, we probably can’t help you. It seems like some non-Xfce application has crashed. You should report this to whomever writes/maintains that software. However, the debugging strategies below will probably still be useful to that person.
What’s a debug build?
If you’ve submitted debugging information before, you might have been asked to recompile and use a debug build (or an unstripped build). Unfortunately, most distributions/OSes ship without debugging information in their binaries. While this decreases file size (often dramatically) and can increase performance to some (probably small) extent, it makes it very difficult to get useful debugging information.
If it isn’t possible for you to run a debug/unstripped build for some reason, please still try to follow the steps below. A stripped build may still yield some useful information to the developer, though they may end up asking you to use a debug build later on. To create a debug build, you’ll need to recompile the software by hand, passing ‘–enable-debug=yes’ to the configure script.
So what do I do now?
Well, now that you know what crashed, and that you hopefully have a debug build, you can try to help figure out why. The basic procedure is the same, but different applications may need to be handled in different ways.
- Quit Xfce (and X), and drop down to a normal console.
- If you get a graphical login prompt, try pressing Alt+Ctrl+F1 to get a console. You may have to log in at this point, and you may have to stop your graphical login manager. Unfortunately, this is distribution/OS-dependent, so I probably can’t help you.
- From the console, run ‘ulimit -c unlimited’. This will allow crashed applications launched from this console to leave behind ‘core’ files that help with debugging.
- Next run ‘startxfce4′ to start Xfce.
- Do what you did to make Xfce crash.
- After dropping back to console, look for a file that starts with ‘core’. In some cases this might be the word ‘core’ followed by a dot and then a number. If you have several of these files, check the dates. The one you’re looking for should be the one with the most recent date. On some systems, the file name might be the name of the application, followed by a dot, and then the word ‘core’. For reference, let’s call this file $CORE.
- Next we’ll use the debugger. From the console, run ‘gdb xfce4-session $CORE’, substituting $CORE for the filename we found above.
- gdb will spit out some text. If you get something asking you to press enter to continue, do so until you get a ‘(gdb)’ prompt.
- At this point gdb will say something about the app crashing. At the prompt, type ‘bt’ and press enter.
- A lot of useful information should be printed out. If you need to press enter to get more screens of data, do so. Copy and paste this into a bug report.
- Start Xfce.
- Close all windows and applications. It’s OK to leave the standard desktop apps running, like that panel.
- Start a single terminal program, like Terminal or xterm.
- Type ‘ulimit -c unlimited’ in the terminal
- Type ‘pkill xfwm4′ in the terminal. At this point, your window borders should disappear.
- So you can continue typing, keep the mouse cursor over the terminal window. Type ‘xfwm4′ in the terminal window.
- Do whatever it was you did to make xfwm4 crash. If this means opening and interacting with an application, that’s fine. Just try to keep the terminal window unobscured.
- When xfwm4 crashes, move the mouse cursor over the terminal window, and type ‘xfwm4 &’ again to start it up and put it in the background.
- In the terminal, look in the current directory for a core file. This file may simply be named ‘core’, or it might be called ‘core’, followed by a dot and some numbers. On some systems, it might be ‘xfwm4.core’. If there are several files of this name, find the one with the date and time of when xfwm4 just crashed.
- Type ‘gdb xfwm4 $CORE’ into the terminal, replacing ‘$CORE’ with the filename you just found above.
- Some text should scroll by. Press the enter key if you need to, until you come to a ‘(gdb)’ prompt. There should be some information about xfwm4 crashing.
- Type ‘bt’ at the prompt, and press enter until you get another prompt. Copy and paste all of this output into a bug report.
- While Xfce is running, open a terminal.
- If you are using Xfce 4.4, type ‘xfce4-panel -x’ to cause the panel to exit. If you are using Xfce 4.2, type ‘pkill xfce4-panel’ to kill it.
- Start the panel again, but inside the debugger. Run ‘gdb xfce4-panel’.
- When you get the ‘(gdb)’ prompt, type ‘run’. The panel should start.
- Do whatever you did to make the panel crash. Since the debugger will halt the panel when it crashes, the panel windows themselves will likely not disappear from the screen, though you will be unable to interact with them.
- In the debugger, you should see another ‘(gdb)’ prompt, and a message about the panel crashing. Type ‘bt’ at the prompt.
- If the output is long, press enter several times to get it all. Paste this into a bug report.
Panel ‘internal’ plugins
Since ‘internal’ panel plugins are actually run inside the panel process, you can debug this in exactly the same way as you would for the panel itself.
Panel ‘external’ plugins
NB: This method will only work if you can successfully add the plugin to the panel without it crashing. If the act of adding the plugin to the panel causes it to crash, there isn’t an easy way to debug it.
- With the panel running, add the offending plugin back to the panel. It’s easiest if you only have one instance of the plugin in the panel when you’re trying to debug this.
- Open a terminal and find the PID (process ID) of the plugin process. Depending on your system, you can probably type ‘ps eax’ or simply ‘ps e’ to list all running processes. You can either manually look down the entire list, or use grep to try to find your plugin. A command like ‘ps eax | grep xfce4-mailwatch’ should find what you need. Obviously replace ‘xfce4-mailwatch’ above with the binary name of the crashing plugin. If you’re not sure what that is, either look at the complete list, or dig around in /usr/lib/xfce4/panel-plugins/ to figure out what it’s called. At any rate, the 3-, 4-, ot 5-digit number should be the plugin’s process ID. Let’s call it $PID.
- Start the debugger and attach it to the running plugin process. Run ‘gdb $PLUGIN_NAME $PID’ in the terminal. Replace ‘$PLUGIN_NAME’ with the binary name of the plugin, and ‘$PID’ with the process ID found above.
- The debugger should start, attach to the program, and eventually give you a ‘(gdb)’ prompt. At this point, it has interrupted execution, so type ‘continue’ at the prompt.
- Now go back to the panel, and reproduce the crash. Since the debugger will halt the program, the plugin shouldn’t disappear from the panel, but you won’t be able to interact with it anymore.
- Go back to the debugger. There should be a message about the plugin crashing, followed by a ‘(gdb)’ prompt. Type ‘bt’ at the prompt, and hit enter if there are several screens of output. Paste this output into a bug report
- With Xfce running, open a terminal.
- If xfdesktop is running, kill it by typing ‘xfdesktop –quit’ in the terminal. If that doesn’t work, type ‘pkill xfdesktop’. (With xfdesktop 4.5.91 and later, the ‘–quit’ option is required, otherwise xfdesktop will respawn itself automatically.)
- Type ‘gdb xfdesktop’ into the terminal.
- At the ‘(gdb)’ prompt, type ‘run’.
- Try to reproduce the crash. When it does crash, the xfdesktop window and/or icons will not disappear, as gdb will halt the application. You will not be able to interact with the desktop anymore, though.
- Go back to the debugger. There should be a message about xfdesktop crashing, followed by a ‘(gdb)’ prompt. Type ‘bt’ at the prompt. The debugger will print out a bunch of data; press enter several times if there are multiple screens of data. Paste all this into a bug report.
- With Xfce running, open a terminal.
- If xfce-mcs-manager is running, kill it by typing ‘pkill xfce-mcs-manager’ in the terminal.
- Type ‘gdb xfce-mcs-manager’ into the terminal.
- At the ‘(gdb)’ prompt, type ‘run –no-daemon-debug’.
- Try to reproduce the crash.
- Go back to the debugger. There should be a message about xfce-mcs-manager crashing, followed by a ‘(gdb)’ prompt. Type ‘bt’ at the prompt. The debugger will print out a bunch of data; press enter several times if there are multiple screens of data. Paste all this into a bug report.
This document is not quite finished or polished. Please send any comments or suggestions to Brian.
last modified 2 dec 2008 at 23:35.