all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help getting backtrace in gdb
@ 2017-06-26 18:33 Kaushal Modi
  2017-06-27 21:11 ` Noam Postavsky
  0 siblings, 1 reply; 12+ messages in thread
From: Kaushal Modi @ 2017-06-26 18:33 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 2489 bytes --]

Hello,

It has been a while (about a year) since I did backtracing in gdb. I
followed my notes from then to look at a backtrace for an emacs crash, but
it's not working.

km²~/downloads/:git/emacs/src> gdb ./emacs
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-75.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/kmodi/downloads/git/emacs/src/emacs...done.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from
terminal]
DISPLAY = :1.0
TERM = tmux-24bits
Breakpoint 1 at 0x55c782: file emacs.c, line 364.
Temporary breakpoint 2 at 0x580423: file sysdep.c, line 1022.
(gdb) break Fsignal
Breakpoint 3 at 0x605535: file eval.c, line 1508.
(gdb) r -Q
Starting program: /home/kmodi/downloads/git/emacs/src/emacs -Q

(emacs:19646): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup:
assertion 'source != NULL' failed

Backtrace:
[0x0]
[0x0]
[0x0]
During startup program terminated with signal SIGSEGV, Segmentation fault.
(gdb) bt
No stack.
You can't do that without a process to debug.

(If interested, this is what causes the crash on emacs -Q:
http://lists.gnu.org/archive/html/emacs-orgmode/2017-06/msg00508.html )

The difference in behavior I see is that the breakpoint on Fsignal is not
working.

I have built emacs from the latest version of master branch with these
options:

./configure options:
  --with-modules --prefix=/home/kmodi/usr_local/apps/6/emacs/master
'--program-transform-name=s/^ctags$/ctags_emacs/' 'CPPFLAGS=-fgnu89-inline
-I/home/kmodi/usr_local/6/include -I/usr/include/freetype2 -I/usr/include'
'CFLAGS=-ggdb3 -O0' 'CXXFLAGS=-ggdb3 -O0'
'LDFLAGS=-L/home/kmodi/usr_local/6/lib -L/home/kmodi/usr_local/6/lib64
-ggdb3'

Features:
  XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11 MODULES

Has something changed about configure (some new flag that I need to add?)
to enable debug in gdb?
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 3367 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-06-26 18:33 Help getting backtrace in gdb Kaushal Modi
@ 2017-06-27 21:11 ` Noam Postavsky
  2017-06-27 22:01   ` Kaushal Modi
  0 siblings, 1 reply; 12+ messages in thread
From: Noam Postavsky @ 2017-06-27 21:11 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Emacs developers

On Mon, Jun 26, 2017 at 2:33 PM, Kaushal Modi <kaushal.modi@gmail.com> wrote:

> (gdb) break Fsignal
> Breakpoint 3 at 0x605535: file eval.c, line 1508.
> (gdb) r -Q
> Starting program: /home/kmodi/downloads/git/emacs/src/emacs -Q
>
> (emacs:19646): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup:
> assertion 'source != NULL' failed
>
> Backtrace:
> [0x0]
> [0x0]
> [0x0]
> During startup program terminated with signal SIGSEGV, Segmentation fault.
> (gdb) bt
> No stack.

It looks like maybe the stack got corrupted so much that gdb can't
find it? (i.e., just bad luck on your part)

> (If interested, this is what causes the crash on emacs -Q:
> http://lists.gnu.org/archive/html/emacs-orgmode/2017-06/msg00508.html )
>
> The difference in behavior I see is that the breakpoint on Fsignal is not
> working.

I don't think you called Fsignal though? To be clear, the signal
referred to by Fsignal is not related to "signal SIGSEGV", in case
that's what you were thinking.

You can try evaluating (signal 'wrong-number-of-arguments '(x y)) to
see if your Fsignal breakpoint is working.

>
> I have built emacs from the latest version of master branch with these
> options:
>
> ./configure options:
>   --with-modules --prefix=/home/kmodi/usr_local/apps/6/emacs/master
> '--program-transform-name=s/^ctags$/ctags_emacs/' 'CPPFLAGS=-fgnu89-inline
> -I/home/kmodi/usr_local/6/include -I/usr/include/freetype2 -I/usr/include'
> 'CFLAGS=-ggdb3 -O0' 'CXXFLAGS=-ggdb3 -O0'
> 'LDFLAGS=-L/home/kmodi/usr_local/6/lib -L/home/kmodi/usr_local/6/lib64
> -ggdb3'

> Has something changed about configure (some new flag that I need to add?) to
> enable debug in gdb?

Nothing should have changed, as far as I know, and those options look
fine (though I wonder what the -fgnu89-inline flag is for).
You can try adding --enable-checking=yes which can help catch errors
earlier (hopefully before your stack gets too corrupted).



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-06-27 21:11 ` Noam Postavsky
@ 2017-06-27 22:01   ` Kaushal Modi
  2017-06-27 23:27     ` Noam Postavsky
  0 siblings, 1 reply; 12+ messages in thread
From: Kaushal Modi @ 2017-06-27 22:01 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 3025 bytes --]

On Tue, Jun 27, 2017 at 5:11 PM Noam Postavsky <
npostavs@users.sourceforge.net> wrote:

> On Mon, Jun 26, 2017 at 2:33 PM, Kaushal Modi <kaushal.modi@gmail.com>
> wrote:
>
> It looks like maybe the stack got corrupted so much that gdb can't
> find it? (i.e., just bad luck on your part)
>

Probably, or probably something is not right with Fsignal. See below.


> > (If interested, this is what causes the crash on emacs -Q:
> > http://lists.gnu.org/archive/html/emacs-orgmode/2017-06/msg00508.html )
> >
> > The difference in behavior I see is that the breakpoint on Fsignal is not
> > working.
>
> I don't think you called Fsignal though?


My assumption was that Fsignal would get called before the seg fault.


> To be clear, the signal
> referred to by Fsignal is not related to "signal SIGSEGV", in case
> that's what you were thinking.
>

OK.


> You can try evaluating (signal 'wrong-number-of-arguments '(x y)) to
> see if your Fsignal breakpoint is working.
>

Nope, it does not work..
I get the backtrace in the gdb-launched emacs but no breakpoint in the gdb.

The gdb shows just this:

GNU gdb (GDB) Red Hat Enterprise Linux (7.2-75.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/kmodi/downloads/git/emacs/src/emacs...done.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from
terminal]
DISPLAY = :1.0
TERM = screen-256color
Breakpoint 1 at 0x55c7aa: file emacs.c, line 364.
Temporary breakpoint 2 at 0x58044b: file sysdep.c, line 1022.
(gdb) break Fsignal
Breakpoint 3 at 0x60555d: file eval.c, line 1508.
(gdb) r -Q
Starting program: /home/kmodi/downloads/git/emacs/src/emacs -Q

(emacs:6024): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup:
assertion 'source != NULL' failed

Should I be concerned about this part:

=====
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from
terminal]
=====

.. because I do not know that answers that y/n question.. it happens
automatically.

> Has something changed about configure (some new flag that I need to add?)
> to
> > enable debug in gdb?
>
> Nothing should have changed, as far as I know, and those options look
> fine (though I wonder what the -fgnu89-inline flag is for).
> You can try adding --enable-checking=yes which can help catch errors
> earlier (hopefully before your stack gets too corrupted).
>

Thanks for pointing that out! I added that switch many years ago probably
because emacs did not get built without that on RHEL 5.x. Today I am on
RHEL 6.6, and I don't seem to need that any more.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 4804 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-06-27 22:01   ` Kaushal Modi
@ 2017-06-27 23:27     ` Noam Postavsky
  2017-06-27 23:50       ` Davis Herring
  2017-10-03 21:09       ` Kaushal Modi
  0 siblings, 2 replies; 12+ messages in thread
From: Noam Postavsky @ 2017-06-27 23:27 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: Emacs developers

On Tue, Jun 27, 2017 at 6:01 PM, Kaushal Modi <kaushal.modi@gmail.com> wrote:
>
> My assumption was that Fsignal would get called before the seg fault.

I would not expect it to be called, if you're strictly following the
recipe for Bug#27504.

>>
>> You can try evaluating (signal 'wrong-number-of-arguments '(x y)) to
>> see if your Fsignal breakpoint is working.
>
>
> Nope, it does not work..
> I get the backtrace in the gdb-launched emacs but no breakpoint in the gdb.
>
> The gdb shows just this:

Hmm, it didn't stop at all? Can you put a breakpoint in 'main'?

> Should I be concerned about this part:
>
> =====
> SIGINT is used by the debugger.
> Are you sure you want to change it? (y or n) [answered Y; input not from
> terminal]
> =====

No that's normal, it's from this thing in emacs/src/.gdbinit:

# Don't enter GDB when user types C-g to quit.
# This has one unfortunate effect: you can't type C-c
# at the GDB to stop Emacs, when using X.
# However, C-z works just as well in that case.
handle 2 noprint pass



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-06-27 23:27     ` Noam Postavsky
@ 2017-06-27 23:50       ` Davis Herring
  2017-06-28  0:05         ` Noam Postavsky
  2017-10-03 21:09       ` Kaushal Modi
  1 sibling, 1 reply; 12+ messages in thread
From: Davis Herring @ 2017-06-27 23:50 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: Emacs developers, Kaushal Modi

> # Don't enter GDB when user types C-g to quit.
> # This has one unfortunate effect: you can't type C-c
> # at the GDB to stop Emacs, when using X.
> # However, C-z works just as well in that case.
> handle 2 noprint pass

So how do you break back into the debugger?  C-z would just suspend gdb 
itself (and probably emacs if it is an inferior rather than an attached 
process)...

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or 
too sparse, it is because mass-energy conversion has occurred during 
shipping.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-06-27 23:50       ` Davis Herring
@ 2017-06-28  0:05         ` Noam Postavsky
  0 siblings, 0 replies; 12+ messages in thread
From: Noam Postavsky @ 2017-06-28  0:05 UTC (permalink / raw)
  To: Davis Herring; +Cc: Kaushal Modi, Emacs developers

On Tue, Jun 27, 2017 at 7:50 PM, Davis Herring <herring@lanl.gov> wrote:
>
> So how do you break back into the debugger?  C-z would just suspend gdb
> itself (and probably emacs if it is an inferior rather than an attached
> process)...

No, through some magic, C-z in the XTerm running gdb does in fact
bring up the gdb prompt.

See "Getting control to the debugger" in etc/DEBUG for some other possibilities.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-06-27 23:27     ` Noam Postavsky
  2017-06-27 23:50       ` Davis Herring
@ 2017-10-03 21:09       ` Kaushal Modi
  2017-10-04  5:38         ` Eli Zaretskii
  1 sibling, 1 reply; 12+ messages in thread
From: Kaushal Modi @ 2017-10-03 21:09 UTC (permalink / raw)
  To: Emacs developers; +Cc: Noam Postavsky

[-- Attachment #1: Type: text/plain, Size: 2798 bytes --]

On Tue, Jun 27, 2017 at 7:27 PM Noam Postavsky <
npostavs@users.sourceforge.net> wrote:

> On Tue, Jun 27, 2017 at 6:01 PM, Kaushal Modi <kaushal.modi@gmail.com>
> wrote:
> >
> > My assumption was that Fsignal would get called before the seg fault.
>
> I would not expect it to be called, if you're strictly following the
> recipe for Bug#27504.
>
> >>
> >> You can try evaluating (signal 'wrong-number-of-arguments '(x y)) to
> >> see if your Fsignal breakpoint is working.
> >
> >
> > Nope, it does not work..
>

Hello all,

This is a non-Emacs question .. I am having trouble getting gdb to work.
But I need gdb to work to help provide more debug info for an Emacs bug.

If I use the gdb that has shipped with my RHEL OS, gdb is unable to catch
any of the errors that happen in Emacs.. even evaluating (error "foo") does
not give control back to gdb.

gdb version:

GNU gdb (GDB) Red Hat Enterprise Linux (7.2-75.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.

So I built the latest gdb from source (v8.0.1), and there I get this
another issue (see below):

GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./emacs...done.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from
terminal]
DISPLAY = :1.0
TERM = screen-256color
Breakpoint 1 at 0x55e4e7: file emacs.c, line 364.
Temporary breakpoint 2 at 0x582a67: file sysdep.c, line 1031.
(gdb) break Fsignal
Breakpoint 3 at 0x606ee5: file eval.c, line 1514.
(gdb) r -Q
Starting program: /home/kmodi/downloads/git/emacs/src/emacs -Q
Could not trace the inferior process.
Error: ptrace: No such processDuring startup program exited with code 127.
(gdb) q

Can I get help getting gdb working?
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 4265 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-10-03 21:09       ` Kaushal Modi
@ 2017-10-04  5:38         ` Eli Zaretskii
  2017-10-04 10:53           ` Kaushal Modi
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2017-10-04  5:38 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: npostavs, emacs-devel

> From: Kaushal Modi <kaushal.modi@gmail.com>
> Date: Tue, 03 Oct 2017 21:09:14 +0000
> Cc: Noam Postavsky <npostavs@users.sourceforge.net>
> 
> (gdb) r -Q
> Starting program: /home/kmodi/downloads/git/emacs/src/emacs -Q
> Could not trace the inferior process.
> Error: ptrace: No such processDuring startup program exited with code 127.

This is your problem: GDB is unable to call the debugging APIs on the
Emacs process.  I'm guessing you need some privilege to do that, and
your user lacks it, or your system configuration prevents it.

Could this be relevant:

  https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace_Protection



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-10-04  5:38         ` Eli Zaretskii
@ 2017-10-04 10:53           ` Kaushal Modi
  2017-10-04 11:08             ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Kaushal Modi @ 2017-10-04 10:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Noam Postavsky, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

On Wed, Oct 4, 2017, 1:39 AM Eli Zaretskii <eliz@gnu.org> wrote:

> This is your problem:


I know :) That's why I need help. I am just putting this out in the list in
the case others saw this issue too and got around it.

GDB is unable to call the debugging APIs on the
> Emacs process.  I'm guessing you need some privilege to do that, and
> your user lacks it, or your system configuration prevents it.
>
> Could this be relevant:
>
>
> https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace_Protection


My searching also ended up with the same result. I am on RHEL 6.6 though.
I'll talk to the sysadmins to learn if they recently disabled ptrace. If
that's the case, then I'll never be able to run gdb until I get my own
GNU/Linux machine. (It sounds absurd that one can't use gdb if they don't
have sudo rights.)

Also, with older gdb version, that ships with my OS, I don't get that
ptrace error, but the gdb is not catching any exceptions from emacs. While
in the latest gdb 8.0.1, I get ptrace error. So it could be use that the
newer version is throwing an error where needed?

Thanks.
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1880 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-10-04 10:53           ` Kaushal Modi
@ 2017-10-04 11:08             ` Eli Zaretskii
  2017-10-06 17:35               ` Kaushal Modi
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2017-10-04 11:08 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: npostavs, emacs-devel

> From: Kaushal Modi <kaushal.modi@gmail.com>
> Date: Wed, 04 Oct 2017 10:53:00 +0000
> Cc: Emacs developers <emacs-devel@gnu.org>, Noam Postavsky <npostavs@users.sourceforge.net>
> 
> Also, with older gdb version, that ships with my OS, I don't get that ptrace error, but the gdb is not catching
> any exceptions from emacs. While in the latest gdb 8.0.1, I get ptrace error. So it could be use that the newer
> version is throwing an error where needed?

I guess an older GDB simply doesn't tell you that ptrace failed, but
it fails all the same.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-10-04 11:08             ` Eli Zaretskii
@ 2017-10-06 17:35               ` Kaushal Modi
  2017-10-06 17:42                 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Kaushal Modi @ 2017-10-06 17:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel, npostavs

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

On Wed, Oct 4, 2017 at 7:09 AM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Kaushal Modi <kaushal.modi@gmail.com>
> > Date: Wed, 04 Oct 2017 10:53:00 +0000
> > Cc: Emacs developers <emacs-devel@gnu.org>, Noam Postavsky <
> npostavs@users.sourceforge.net>
> >
> > Also, with older gdb version, that ships with my OS, I don't get that
> ptrace error, but the gdb is not catching
> > any exceptions from emacs. While in the latest gdb 8.0.1, I get ptrace
> error. So it could be use that the newer
> > version is throwing an error where needed?
>

Finally got GDB working.. the solution was embarrassing.. needed to restart
my machine.. it had an uptime of around a year.

(Now, will come back with some useful backtrace results if I can still
recreate those disappearing line numbers after the machine reboot... sigh.)
-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 1464 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Help getting backtrace in gdb
  2017-10-06 17:35               ` Kaushal Modi
@ 2017-10-06 17:42                 ` Eli Zaretskii
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2017-10-06 17:42 UTC (permalink / raw)
  To: Kaushal Modi; +Cc: npostavs, emacs-devel

> From: Kaushal Modi <kaushal.modi@gmail.com>
> Date: Fri, 06 Oct 2017 17:35:06 +0000
> Cc: emacs-devel@gnu.org, npostavs@users.sourceforge.net
> 
> Finally got GDB working..

Congratulations!



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-10-06 17:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-26 18:33 Help getting backtrace in gdb Kaushal Modi
2017-06-27 21:11 ` Noam Postavsky
2017-06-27 22:01   ` Kaushal Modi
2017-06-27 23:27     ` Noam Postavsky
2017-06-27 23:50       ` Davis Herring
2017-06-28  0:05         ` Noam Postavsky
2017-10-03 21:09       ` Kaushal Modi
2017-10-04  5:38         ` Eli Zaretskii
2017-10-04 10:53           ` Kaushal Modi
2017-10-04 11:08             ` Eli Zaretskii
2017-10-06 17:35               ` Kaushal Modi
2017-10-06 17:42                 ` Eli Zaretskii

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.