Jump to content
  • Advertisement
Sign in to follow this  
FGFS

Debug With Gdb

This topic is 793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

I don't remember what I've changed, but now at exit my app crashes. gdb backtrace as below. What to do? I can't read that.

Many thanks

 

 

(gdb) bt
#0  0x00007ffff5d2d418 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff5d2f01a in __GI_abort () at abort.c:89
#2  0x00007ffff5d6f72a in __libc_message (do_abort=do_abort@entry=2,
    fmt=fmt@entry=0x7ffff5e886b0 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff5d77f4a in malloc_printerr (ar_ptr=<optimized out>, ptr=<optimized out>,
    str=0x7ffff5e8548f "free(): invalid pointer", action=3) at malloc.c:5007
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:3868
#5  0x00007ffff5d7babc in __GI___libc_free (mem=<optimized out>) at malloc.c:2969
#6  0x00007fffc58cc698 in __gnu_cxx::new_allocator<int>::deallocate(int*, unsigned long) ()
   from /media/michael/DATA/X-Plane_10/Resources/plugins/XPLM_64.so
#7  0x00007fffc58cbcbc in std::_Vector_base<int, std::allocator<int> >::_M_deallocate(int*, unsigned long) ()
   from /media/michael/DATA/X-Plane_10/Resources/plugins/XPLM_64.so
#8  0x00007fffc58ca8f5 in std::_Vector_base<int, std::allocator<int> >::~_Vector_base() ()
   from /media/michael/DATA/X-Plane_10/Resources/plugins/XPLM_64.so
#9  0x00007fffc58ca3d0 in std::vector<int, std::allocator<int> >::~vector() ()
   from /media/michael/DATA/X-Plane_10/Resources/plugins/XPLM_64.so
#10 0x00007ffff5d3235a in __cxa_finalize (d=0x7fffb702d880) at cxa_finalize.c:56
#11 0x00007fffb6e03443 in __do_global_dtors_aux ()
   from /media/michael/DATA/X-Plane_10/Aircraft/General Aviation/P4/plugins/p4/64/lin.xpl
#12 0x00007fffffff8950 in ?? ()
#13 0x00007ffff7ded257 in _dl_close_worker (map=<optimized out>, force=<optimized out>) at dl-close.c:286
Backtrace stopped: frame did not save the PC
(gdb)
 

 

Share this post


Link to post
Share on other sites
Advertisement

I don't remember what I've changed

I don't have any suggestions as to what's wrong, but the quoted part seems to indicate you do not currently have any form of revision control system in place?

 

If you do not, I highly advise you to start using it, making you able to track changes you've done and not have to worry about accidentally overwriting everything you've done, etc.

Personally, I use Perforce, but GitHub, SVN also keep being mentioned by people. 

Share this post


Link to post
Share on other sites

I guess it's something with my class:

 

class Ausfaelle {
public:
    int index, active, color, height;
    float drValue;
    std::string label;
    Ausfaelle(int index, int active, int color, float drValue, int height, std::string label); 
    ~Ausfaelle();

 

 

I got the previous crash without

    ~Ausfaelle();

but with that I get undefined symbol and no crash. My app doesn't even load.

undefined symbol: _ZN9AusfaelleD1Ev

New to classes so many thanks.

Share this post


Link to post
Share on other sites
got the previous crash without     ~Ausfaelle(); but with that I get undefined symbol and no crash. My app doesn't even load. undefined symbol: _ZN9AusfaelleD1Ev

 

~Ausfaelle(); is the declaration of a class destructor.

If you've declared it, you also need to define it (in the .cpp, like you do with the other normal class functions).

 

I would also suggest you use a debugger and step through, and see where the application crashes.

 

 

EDIT: That said, I don't see your class as needing a custom destructor. If you do not provide one, a default destructor is generated for you. You need a custom destructor in certain cases*, but I don't think your case requires one. I think something else is going on. Stepping through with a debugger seems like the best bet.

 

*Further reading here: Rule of three

Edited by Lactose!

Share this post


Link to post
Share on other sites

I debug with Eclipse but it crashes after my x-plane plugin has finished. Now I do:

in one.cpp:

Ausfaelle::Ausfaelle(int a, int b, int c, float d, int e, std::string f) {
    index = a;
    active = b;
    color = c;
    drValue = d;
    height = e;
    label = f;
}

Ausfaelle::~Ausfaelle()
{
}

in one.h:

class Ausfaelle {
public:
    int index, active, color, height;
    float drValue;
    std::string label;
    Ausfaelle(int index, int active, int color, float drValue, int height, std::string label);  
    ~Ausfaelle();

};

in main.cpp:

 

    std::list<Ausfaelle>Ausfalllinie;
    std::list<Ausfaelle>::iterator it;

 

        for (it=Ausfalllinie.begin(); it != Ausfalllinie.end(); ++it)
    {
           Ausfaelle  test = *it;

...

Many thanks

Share this post


Link to post
Share on other sites

The stacktrace in the original post indicates a double deletion of an object of static storage duration (ie. a global object).  The likely cause is the lack of a proper copy constructor or copy assignment operator in a class that contains pointers and inattention to the copy semantics of the objects.

 

A grand tool to use to analyze exactly these errors is 'valgrind'.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!