ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.