LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-03-2012, 05:33 AM   #1
meenakshi.khurana
LQ Newbie
 
Registered: Mar 2010
Location: India
Distribution: Fedora,Redhat
Posts: 19

Rep: Reputation: 5
why gdb shows ?? in bt


While debugging issues, gdb sometimes do not show full stack trace causing difficulty in debugging issues. Here is one sample example:

Code:
(gdb) bt 
#0  0x08058ec1 in encode_dlg (dlg_ref_id=6777, encode_dlg=0x1610040) at encode_struct.c:489
#1  0x0805afd3 in log_dlg (dlg_ref_id=0) at log_dlg.c:8
#2  0x00000000 in ?? ()
Can anyone help me with this?? Why frame 2 is not showing me the caller of log_dlg function.

What's the reason gdb shows only ?? in bt in some cases. Whats missing in this case.
 
Old 01-03-2012, 10:39 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
The stack might be corrupted. Example:

Code:
void bar (int *p)
{
    memset (p, 0, 100*sizeof (int));
}

void (foo (void)
{
    int a[10];

    bar (a);
}
 
Old 01-03-2012, 11:04 PM   #3
meenakshi.khurana
LQ Newbie
 
Registered: Mar 2010
Location: India
Distribution: Fedora,Redhat
Posts: 19

Original Poster
Rep: Reputation: 5
Then how can i debug the code with corrupted stack?
 
Old 01-04-2012, 04:02 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Set a breakpoint at log_dlg.c:8, and backtrace (bt) when the program reaches that point.
 
Old 01-04-2012, 04:46 AM   #5
meenakshi.khurana
LQ Newbie
 
Registered: Mar 2010
Location: India
Distribution: Fedora,Redhat
Posts: 19

Original Poster
Rep: Reputation: 5
Sorry... I forgot to mention... The problem occurs once in a while but not for every request. Say once in months. I want to understand what goes wrong at that time.

I just have core with me now. Can that help me?
 
Old 01-04-2012, 06:05 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Debugging isn't an exact science, it's more like an art; it requires knowledge, experience, and luck... For first try 'bt full' and examine every shown variable carefully.
 
Old 01-05-2012, 12:02 AM   #7
meenakshi.khurana
LQ Newbie
 
Registered: Mar 2010
Location: India
Distribution: Fedora,Redhat
Posts: 19

Original Poster
Rep: Reputation: 5
I know that.... and i have already tried all options like bt, frames and all. Now i am moving towards analyzing registers... I just thought if anybody can help me with some useful link or doc for further information on that.

Anyways Thanks for your help.
 
Old 02-27-2022, 08:48 AM   #8
aruna.km
LQ Newbie
 
Registered: Feb 2022
Posts: 1

Rep: Reputation: 0
I encounter the same problem

This happens for me also. seg fault happens only at sometime not all time, also gdb trace at ??
Any information would be helpful
 
Old 02-27-2022, 09:57 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by aruna.km View Post
This happens for me also. seg fault happens only at sometime not all time, also gdb trace at ?? Any information would be helpful
Then you probably should open your own question, since this thread had been closed for *TEN YEARS* before you reopened it. Also, you're not providing any details at all, such as version/distro of Linux, desktop GUI you're using, etc.
 
Old 02-27-2022, 11:46 AM   #10
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
@aruna.km
As a start, run your program with `valgrind`, and fix every problem it shows.

Also make sure to compile with options `-Wall -W -pedantic -Werror`. If your compiler is gcc, add option `-fanalyzer`.

There are other programs that might help finding problems, they are called `static analyzers` or `linters`.

Last edited by NevemTeve; 02-27-2022 at 12:59 PM.
 
Old 02-27-2022, 01:27 PM   #11
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,264
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by aruna.km View Post
This happens for me also. seg fault happens only at sometime not all time, also gdb trace at ??
Any information would be helpful
You have posted to a ten year old thread so your post may not attract current participants able to offer help.

Also, though your problem may seem similar when looking at a single error message, your code is different and others cannot offer any specific advice without knowing what the code is doing, or is supposed to be doing.

Please consider posting your own thread with enough detail so that others may understand your problem and offer more specific suggestions to fix it.

Please review the Site FAQ for guidance in asking well formed questions. Especially visit the link from that page, How to Ask Questions the Smart Way for discussion of things to consider when asking others for help.

Welcome to the LQ Programming forum, and good luck!

Last edited by astrogeek; 02-27-2022 at 01:28 PM. Reason: ptosy
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gdb shows <<C++-namespaces>> dayalan_cse Programming 1 12-28-2006 11:10 AM
normal gdb and spec gdb for kgdb Igor007 Programming 1 09-23-2005 04:15 PM
normal gdb and spec gdb for kgdb Igor007 Linux - Newbie 1 09-23-2005 01:41 PM
gdb .. looking for 32 bit gdb.. for ia64 suse.. nkshirsagar SUSE / openSUSE 0 12-09-2004 03:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration