public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* I'm a beginner and need help about "Segmentation fault" error.
       [not found] <394886388.1091427.1604422440532.ref@mail.yahoo.com>
@ 2020-11-03 16:54 ` Jason Long
  2020-11-05 13:43   ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Long @ 2020-11-03 16:54 UTC (permalink / raw)
  To: gdb

Hello,
I'm using Debian 10.6 x86_64 and when I want to run a program then it show me "Segmentation fault" error.
How can use gdb to find the reason of it?
I used strace to generate an output and posted it here: https://pastebin.fun/NY4RUEmyzO

I'm thankful if anyone advice me step by step.

Thank you.

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

* Re: I'm a beginner and need help about "Segmentation fault" error.
  2020-11-03 16:54 ` I'm a beginner and need help about "Segmentation fault" error Jason Long
@ 2020-11-05 13:43   ` Simon Marchi
  2020-11-06 18:10     ` Jason Long
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2020-11-05 13:43 UTC (permalink / raw)
  To: Jason Long, gdb


On 2020-11-03 11:54 a.m., Jason Long via Gdb wrote:
> Hello,
> I'm using Debian 10.6 x86_64 and when I want to run a program then it show me "Segmentation fault" error.
> How can use gdb to find the reason of it?
> I used strace to generate an output and posted it here: https://pastebin.fun/NY4RUEmyzO
>
> I'm thankful if anyone advice me step by step.
>
> Thank you.
>

Hi Jason,

In its most simple expressioj, just load the program in GDB:

  $ gdb <program>

and run it:

  (gdb) run

If the program crashes (receives a SIGSEGV / segmentation fault signal),
it will stop and you'll be able to inspect the state of the program at
that moment.  For example, you'll be able to use the "backtrace" command
to get an idea of wherwe the program was.

Simon

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

* Re: I'm a beginner and need help about "Segmentation fault" error.
  2020-11-05 13:43   ` Simon Marchi
@ 2020-11-06 18:10     ` Jason Long
  2020-11-07  1:16       ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Long @ 2020-11-06 18:10 UTC (permalink / raw)
  To: gdb, Simon Marchi

Thank you.
I did what you said:

(gdb) run
Starting program: /usr/local/bin/ramme 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".


Program received signal SIGSEGV, Segmentation fault.
0x0000000000e6e0c0 in ?? ()
(gdb) backtrace 
#0  0x0000000000e6e0c0 in ?? ()
#1  0x00007ffff7d85462 in node::http2::Http2Session::Callbacks::Callbacks(bool)
    () from /opt/Ramme/libnode.so
#2  0x00007ffff7d85525 in ?? () from /opt/Ramme/libnode.so
#3  0x00007ffff7fe437a in call_init (l=<optimized out>, argc=argc@entry=1, 
    argv=argv@entry=0x7fffffffe248, env=env@entry=0x7fffffffe258)
    at dl-init.c:72
#4  0x00007ffff7fe4476 in call_init (env=0x7fffffffe258, argv=0x7fffffffe248, 
    argc=1, l=<optimized out>) at dl-init.c:30
#5  _dl_init (main_map=0x7ffff7ffe190, argc=1, argv=0x7fffffffe248, 
    env=0x7fffffffe258) at dl-init.c:119
#6  0x00007ffff7fd60ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#7  0x0000000000000001 in ?? ()
#8  0x00007fffffffe52b in ?? ()
#9  0x0000000000000000 in ?? ()


What is the next step?






On Thursday, November 5, 2020, 05:13:30 PM GMT+3:30, Simon Marchi <simark@simark.ca> wrote: 






On 2020-11-03 11:54 a.m., Jason Long via Gdb wrote:
> Hello,
> I'm using Debian 10.6 x86_64 and when I want to run a program then it show me "Segmentation fault" error.
> How can use gdb to find the reason of it?
> I used strace to generate an output and posted it here: https://pastebin.fun/NY4RUEmyzO
>
> I'm thankful if anyone advice me step by step.
>
> Thank you.

>

Hi Jason,

In its most simple expressioj, just load the program in GDB:

  $ gdb <program>

and run it:

  (gdb) run

If the program crashes (receives a SIGSEGV / segmentation fault signal),
it will stop and you'll be able to inspect the state of the program at
that moment.  For example, you'll be able to use the "backtrace" command
to get an idea of wherwe the program was.

Simon


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

* Re: I'm a beginner and need help about "Segmentation fault" error.
  2020-11-06 18:10     ` Jason Long
@ 2020-11-07  1:16       ` Simon Marchi
  2020-11-09 11:55         ` Anton.Krug
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2020-11-07  1:16 UTC (permalink / raw)
  To: Jason Long, gdb

On 2020-11-06 1:10 p.m., Jason Long via Gdb wrote:
> Thank you.
> I did what you said:
>
> (gdb) run
> Starting program: /usr/local/bin/ramme
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
>
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000e6e0c0 in ?? ()
> (gdb) backtrace
> #0  0x0000000000e6e0c0 in ?? ()
> #1  0x00007ffff7d85462 in node::http2::Http2Session::Callbacks::Callbacks(bool)
>     () from /opt/Ramme/libnode.so
> #2  0x00007ffff7d85525 in ?? () from /opt/Ramme/libnode.so
> #3  0x00007ffff7fe437a in call_init (l=<optimized out>, argc=argc@entry=1,
>     argv=argv@entry=0x7fffffffe248, env=env@entry=0x7fffffffe258)
>     at dl-init.c:72
> #4  0x00007ffff7fe4476 in call_init (env=0x7fffffffe258, argv=0x7fffffffe248,
>     argc=1, l=<optimized out>) at dl-init.c:30
> #5  _dl_init (main_map=0x7ffff7ffe190, argc=1, argv=0x7fffffffe248,
>     env=0x7fffffffe258) at dl-init.c:119
> #6  0x00007ffff7fd60ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
> #7  0x0000000000000001 in ?? ()
> #8  0x00007fffffffe52b in ?? ()
> #9  0x0000000000000000 in ?? ()
>
>
> What is the next step?

The next step would be to compile your program with debug info (-g3) and
without optimization (-O0).

I also suggest you search and read for any GDB tutorial out there, it
will walk you though these steps.

Simon

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

* Re: I'm a beginner and need help about "Segmentation fault" error.
  2020-11-07  1:16       ` Simon Marchi
@ 2020-11-09 11:55         ` Anton.Krug
  0 siblings, 0 replies; 5+ messages in thread
From: Anton.Krug @ 2020-11-09 11:55 UTC (permalink / raw)
  To: simark, hack3rcon, gdb

And when the -g is enabled, do not strip the symbols from the binary. So remove '-s' if you have in the compilation process, and remove 'strip' commands which might be triggered on the compiled object files after they were compiled.
________________________________
From: Gdb <gdb-bounces@sourceware.org> on behalf of Simon Marchi <simark@simark.ca>
Sent: 07 November 2020 01:16
To: Jason Long <hack3rcon@yahoo.com>; gdb@sourceware.org <gdb@sourceware.org>
Subject: Re: I'm a beginner and need help about "Segmentation fault" error.

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

On 2020-11-06 1:10 p.m., Jason Long via Gdb wrote:
> Thank you.
> I did what you said:
>
> (gdb) run
> Starting program: /usr/local/bin/ramme
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
>
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000e6e0c0 in ?? ()
> (gdb) backtrace
> #0  0x0000000000e6e0c0 in ?? ()
> #1  0x00007ffff7d85462 in node::http2::Http2Session::Callbacks::Callbacks(bool)
>     () from /opt/Ramme/libnode.so
> #2  0x00007ffff7d85525 in ?? () from /opt/Ramme/libnode.so
> #3  0x00007ffff7fe437a in call_init (l=<optimized out>, argc=argc@entry=1,
>     argv=argv@entry=0x7fffffffe248, env=env@entry=0x7fffffffe258)
>     at dl-init.c:72
> #4  0x00007ffff7fe4476 in call_init (env=0x7fffffffe258, argv=0x7fffffffe248,
>     argc=1, l=<optimized out>) at dl-init.c:30
> #5  _dl_init (main_map=0x7ffff7ffe190, argc=1, argv=0x7fffffffe248,
>     env=0x7fffffffe258) at dl-init.c:119
> #6  0x00007ffff7fd60ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
> #7  0x0000000000000001 in ?? ()
> #8  0x00007fffffffe52b in ?? ()
> #9  0x0000000000000000 in ?? ()
>
>
> What is the next step?

The next step would be to compile your program with debug info (-g3) and
without optimization (-O0).

I also suggest you search and read for any GDB tutorial out there, it
will walk you though these steps.

Simon

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

end of thread, other threads:[~2020-11-09 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <394886388.1091427.1604422440532.ref@mail.yahoo.com>
2020-11-03 16:54 ` I'm a beginner and need help about "Segmentation fault" error Jason Long
2020-11-05 13:43   ` Simon Marchi
2020-11-06 18:10     ` Jason Long
2020-11-07  1:16       ` Simon Marchi
2020-11-09 11:55         ` Anton.Krug

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).