double free or corruption???

This is a discussion on double free or corruption??? within the C++ Programming forums, part of the General Programming Boards category; Yes, so a program I'm running is giving me this, to me at least, unusual error. Juding from the double ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    3

    Question double free or corruption???

    Yes, so a program I'm running is giving me this, to me at least, unusual error. Juding from the double free or corruption name and the output of the program, which should output some zeros (no that's not all it does), but actually outputs some number * 10^-317, which is similar to but not zero. In another twist it doesn't screw up if I run it through valgrind. What's actually happening is I make a user defined data type, which stores three doubles, and I'm putting 0 in each. I then use the class print function which just outputs the data, formatted pretty like and all. And I get two zeros and a small number like I said. Any hints, what might be going wrong? If it would help to see some code just ask what you'd like to see, I don't really know where the problem is. The program says aborted but it seems to reach the end of execution. But the problem, if it is infact related to that double not being 0 but rather a small number, happens a few statements before the end of the program, and some of those are output so I know it's not being aborted before that.

    *** glibc detected *** double free or corruption (fasttop): 0x000000000054d720 ***

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Compile the program with debug info, load it into gdb, run it until it crashes and get a backtrace. That should give you an idea where the free call is that fails - you'd have to scan the other uses of the variables in question to find out where the actual problem is.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    You can print a backtrace in GDB with the backtrace or bt command.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. double free or corruption (out)
    By Mouser58907 in forum C Programming
    Replies: 5
    Last Post: 02-24-2009, 11:20 PM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. Replies: 7
    Last Post: 11-26-2007, 12:11 PM
  4. Malloc - Free giving double free or corruption error
    By andrew.bolster in forum C Programming
    Replies: 2
    Last Post: 11-02-2007, 06:22 AM
  5. Conversion From C++ To C
    By dicon in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 02:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21