LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-24-2009, 11:19 AM   #1
map250r
Member
 
Registered: Aug 2007
Distribution: Debian Squeeze
Posts: 46

Rep: Reputation: 15
gdb debugger - pointer length differences???


I'm on a 64-bit system. I'm getting a segfault in a program I compiled. When I backtrace it with gdb, the pointer 'this' appears to be a different length in part of the code. Is gdb simply removing unnecessary zeros when it prints the value, or is the code somehow using a 32-bit pointer?

Code:
$ gdb ./qtgeom
GNU gdb 6.8-debian
This GDB was configured as "x86_64-linux gnu"...
(gdb) r
Starting program: /home/mark/projects/qtgeom/qtgeom
[Thread debugging using libthread_db enabled]
[New Thread 0x7f6ccad2f730 (LWP 4667)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f6ccad2f730 (LWP 4667)]
0x00007f6cca90de25 in Handle_Standard_Transient::EndScope (this=0x8606d8)
at ../../../src/Standard/Handle_Standard_Transient.cxx:56
56 if ( Standard::IsReentrant() ?
(gdb) bt
#0 0x00007f6cca90de25 in Handle_Standard_Transient::EndScope (this=0x8606d8)
at ../../../src/Standard/Handle_Standard_Transient.cxx:56
#1 0x00007f6cca90df11 in Handle_Standard_Transient::Assign (this=0x8606d8, anItem=0x20008ad8)
at ../../../src/Standard/Handle_Standard_Transient.cxx:32
#2 0x00007f6cbc021e48 in GEOM_Engine (this=0x8606d0) at ./inc/Handle_GEOM_Application.hxx:78
#3 0x00007f6cbba50e37 in GEOMImpl_Gen (this=0x8606d8) at ./src/GEOMImpl/GEOMImpl_Gen.cpp:85
#4 0x0000000000425974 in QoccApplication (this=0x7fffd2e8df00, argc=@0x7fffd2e8defc, argv=0x7fffd2e8e028,
_internal=263171) at src/qocc/qoccapplication.cpp:60
#5 0x0000000000424836 in main (argc=1, argv=0x7fffd2e8e028) at src/main/main.cpp:52

Compare #3 with #4 - the length of "this" changes. Am I onto something?

Thanks
 
Old 02-24-2009, 01:02 PM   #2
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,533

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by map250r View Post
I'm on a 64-bit system. I'm getting a segfault in a program I compiled. When I backtrace it with gdb, the pointer 'this' appears to be a different length in part of the code. Is gdb simply removing unnecessary zeros when it prints the value, or is the code somehow using a 32-bit pointer?

...

Compare #3 with #4 - the length of "this" changes. Am I onto something?

Thanks
There's not a whole lot to say in this instance. Even if you are "onto something", what course of action can be taken will be anyone's guess.

Please consider posting some code where you think the seg-fault is occurring. Also consider using assert() to determine if the pointer you are trying to address has been initialized properly.

---------------------

Edit:

On line 4 of your 'gdb' output:
Code:
#4 0x0000000000425974 in QoccApplication (this=0x7fffd2e8df00, argc=@0x7fffd2e8defc, argv=0x7fffd2e8e028,
the value for argc seems way off. Did you by chance pass the address of argc vs. the value?

Last edited by dwhitney67; 02-24-2009 at 01:08 PM.
 
Old 02-25-2009, 11:25 AM   #3
map250r
Member
 
Registered: Aug 2007
Distribution: Debian Squeeze
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by dwhitney67 View Post
There's not a whole lot to say in this instance. Even if you are "onto something", what course of action can be taken will be anyone's guess.

Please consider posting some code where you think the seg-fault is occurring. Also consider using assert() to determine if the pointer you are trying to address has been initialized properly.

---------------------

Edit:

On line 4 of your 'gdb' output:
Code:
#4 0x0000000000425974 in QoccApplication (this=0x7fffd2e8df00, argc=@0x7fffd2e8defc, argv=0x7fffd2e8e028,
the value for argc seems way off. Did you by chance pass the address of argc vs. the value?
argv/argc are not used. Also, there's an atsign in argc... which I assume means it's a pointer. It's 4 less than 'this', which sounds right to me. Just enough space for a 32-bit int.

None of this is my code, but apparently I am the only person having trouble with it. Standard_Transient is part of a memory manager, and I really don't want to dig into that. I will put in some asserts in the GEOM code and see what happens.
 
Old 02-25-2009, 11:50 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Maybe you've already found your problem: if this is 32 bits wide in most places but in one place you have a 64-bit this, even if gdb is just truncating zeros, that indicates you might be dereferencing a bad pointer there. And since the pointer argv is mysteriously similar to the questionable this, that tells me you might be dereferencing a pointer to static storage when you shouldn't be.
Kevin Barry

Last edited by ta0kira; 02-25-2009 at 11:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 (GNU DeBugger) plutonas Linux - Software 8 03-19-2013 12:09 PM
GDB debugger breakpoints cleopard Programming 1 05-07-2008 03:15 PM
LXer: Fun with strace and the GDB Debugger LXer Syndicated Linux News 0 05-14-2006 05:54 PM
Problem with gdb, or is there a better debugger for C++? Nightfox Programming 1 01-25-2006 08:16 PM
problem i using emacs with gdb debugger? varala_kanth Linux - Software 2 04-05-2004 01:43 AM

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

All times are GMT -5. The time now is 12:30 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration