unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: The emacs_backtrace "feature"
Date: Fri, 21 Sep 2012 12:37:30 -0700	[thread overview]
Message-ID: <505CC1FA.4070300@cs.ucla.edu> (raw)
In-Reply-To: <83lig3yaci.fsf@gnu.org>

I agree with a lot of points that Eli raised: backtraces can be a
pain.  Still, in my experience these backtraces, limited as they
are, are typically an improvement over not having backtraces.

Going through some of Eli's comments:

>  . Many real-life backtraces are long and quickly scroll off the
>    screen.

That's less of a problem these days.  On GNU and POSIXish
platforms most people run Emacs in an environment where backtraces
are sent to a file, or to a window or a console that has history
that is typically long enough.  It's not perfect, but it's
typically better than not having a backtrace.

>  . Many calls to emacs_backtrace in the current sources limit the
>    number of backtrace frames to 10, but that is an arbitrary
>    limitation which will be too small in most, if not all, situations.

We can change that number if needed.  10 was enough for my use
cases.  Of course no number will be ideal in all cases.  Still, 10
is almost invariably better than 0.

>  . The backtrace is written to the standard error file handle.  Is
>    that handle always guaranteed to be available

No.  But typically it is, and overall we're better off.

>  . using the limited information it provides can be quite
>    difficult, especially if the crash happened in a binary
>    compiled by a different compiler version than yours

I'd say it's more than just "difficult".  It's typically impossible.
A backtrace makes sense only if you have access to the environment
that generated the crash, or a pretty-close clone of that
environment.  In this respect it's no better than a core dump.

Core dumps are better than backtraces if they're available, but
modern GNUish distributions often disable them, alas, and they're
a pain to send via email, and it's nice to have a bit more info
than 'Fatal error 27' when Emacs crashes.

The main point of these backtraces is to help diagnose Emacs
problems after a crash in which a core dump is not available and
where the bug cannot easily be reproduced.  This situation is
becoming increasinly common, and for this situation a backtrace,
even with its limitations, is invaluable.  Anyone with access to
the system where the crash occurred can use GDB or addr2line to
get the source line numbers etc. for the crash.  This is info
that's available in no other way.

Come to think of it, the addr2line stuff should be documented.  I
gave it a shot and installed the following as trunk bzr 110125.

* trouble.texi (Crashing): Document addr2line.
=== modified file 'doc/emacs/trouble.texi'
--- doc/emacs/trouble.texi	2012-09-04 18:29:04 +0000
+++ doc/emacs/trouble.texi	2012-09-21 19:27:37 +0000
@@ -308,13 +308,26 @@

 @noindent
 The number @samp{11} is the system signal number that corresponds to
-the problem, a segmentation fault here.  The hexadecimal program
-addresses can be useful in debugging sessions.  For example, the GDB
-command @samp{list *0x509af6} prints the source-code lines
-corresponding to the @samp{emacs[0x509af6]} entry in the backtrace.
-
-The three dots at the end indicate that Emacs suppressed further
-backtrace entries, in the interest of brevity.
+the problem, a segmentation fault here.  The three dots at the end
+indicate that Emacs suppressed further backtrace entries, in the
+interest of brevity.
+
+The hexadecimal program addresses can be useful in debugging sessions.
+For example, the GDB command @samp{list *0x509af6} prints the
+source-code lines corresponding to the @samp{emacs[0x509af6]} entry in
+the backtrace.  Or, if your system has @command{addr2line}, the
+following shell command outputs a backtrace with source-code line
+numbers:
+
+@example
+sed -n 's/.*\[\(.*\)]$/\1/p' @var{backtrace} |
+  addr2line -Cfip -e @var{bindir}/emacs
+@end example
+
+@noindent
+Here, @var{backtrace} is the name of a text file containing a copy of
+the backtrace, and @var{bindir} is the name of the directory that
+contains the Emacs executable.

 @node After a Crash
 @subsection Recovery After a Crash





  parent reply	other threads:[~2012-09-21 19:37 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-21  9:49 The emacs_backtrace "feature" Eli Zaretskii
2012-09-21  9:58 ` Andreas Schwab
2012-09-21 10:17   ` Eli Zaretskii
2012-09-21 12:00     ` Andreas Schwab
2012-09-21 19:29   ` Florian Weimer
2012-09-21 19:45     ` Paul Eggert
2012-09-24 15:52       ` Steinar Bang
2012-09-21 12:24 ` Óscar Fuentes
2012-09-21 16:35   ` Stefan Monnier
2012-09-21 16:49 ` Stephen J. Turnbull
2012-09-21 17:07   ` Tom Tromey
2012-09-21 17:41   ` Andreas Schwab
2012-09-21 19:37 ` Paul Eggert [this message]
2012-09-22 12:05   ` Richard Stallman
2012-09-22 13:54     ` Christoph Scholtes
2012-09-22 14:23       ` covici
2012-09-24 15:55     ` Steinar Bang
2012-09-24 17:29       ` Paul Eggert
2012-09-22 12:41   ` Eli Zaretskii
2012-09-22 19:28     ` Paul Eggert
2012-09-23 13:05     ` Stephen J. Turnbull
2012-09-23 14:19       ` Andreas Schwab
2012-09-23 19:30         ` Stephen J. Turnbull
2012-09-23 21:01           ` Nix
2012-09-24  5:00             ` Stephen J. Turnbull
2012-09-24  9:29               ` Nix
2012-09-24 23:55                 ` Stephen J. Turnbull
2012-09-29 19:31   ` Juri Linkov
2012-09-29 20:01     ` Eli Zaretskii
2012-09-29 20:51       ` Paul Eggert
2012-09-29 21:19         ` Eli Zaretskii
2012-09-30  1:30           ` Paul Eggert
2012-09-30  9:44             ` messages-buffer-max-lines (was: The emacs_backtrace "feature") Juri Linkov
2012-10-01  5:51               ` messages-buffer-max-lines Paul Eggert
2012-10-01  6:50                 ` messages-buffer-max-lines Chong Yidong
2012-09-30  1:48       ` The emacs_backtrace "feature" Stefan Monnier
2012-09-30  7:14         ` Eli Zaretskii
2012-09-30  7:24           ` Paul Eggert
2012-10-01  2:54         ` Chong Yidong
2012-10-01 11:43           ` Lars Magne Ingebrigtsen
2012-09-21 21:40 ` Richard Stallman
2012-09-22  6:53   ` Stephen J. Turnbull
2012-09-24 14:27   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=505CC1FA.4070300@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).