![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ftp zip files corruption | colesga | Shell Programming and Scripting | 3 | 08-02-2007 08:22 AM |
| *** glibc detected *** free(): invalid next size (normal): 0x0000000000503e70 *** | vbreddy | High Level Programming | 1 | 04-11-2006 09:18 AM |
| NTFS corruption under w2k but not under suse 9.2 | mickepe | Windows & DOS: Issues & Discussions | 4 | 08-05-2005 05:19 PM |
| data corruption with ftp transfer | malcom | UNIX for Advanced & Expert Users | 12 | 08-04-2003 04:38 AM |
| file corruption | shibz | UNIX for Advanced & Expert Users | 5 | 09-06-2002 08:56 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#8
|
|||
|
|||
|
oh thanks for spotting that. i wrote simple loops just to test it out, but obviously i havent been able to get that far.
that is all the code, the entire header file. it compiles fine with no warnings what so ever. maybe its my system? id try running it on my server but i dont want to risk bringing that down. heres a simple driver program, this just hangs, it dosnt even print the message in there that is before the creation of the Dynamicarray objects: Code:
#include <iostream>
#include <string>
#include "Dynamicarray.h"
using namespace std;
int main()
{
cout << "before object creation...";
Dynamicarray <int> newArray(5);
Dynamicarray <string> newArray2;
for(int i = 0; i < newArray.size(); i++)
{
newArray.add(i);
}
cout << "newArray with size of 5: " << endl;
for(int i = 0; i < newArray.size(); i++)
{
cout << " " << newArray.get_val(i) << " ";
}
cout << "newArray2 with type string, undefined size: " << endl;
string s1 = "using";
string s2 = "my";
string s3 = "dynamic";
string s4 = "array..";
string s5 = "with templates";
newArray2.add(s1);
newArray2.add(s2);
newArray2.add(s3);
newArray2.add(s4);
newArray2.add(s5);
for(int i = 0; i < newArray2.size(); i++)
{
cout<< " " << newArray2.get_val(i) << " ";
}
}
|
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
well i wrote another class using templates to see if there was something i was doing wrong there, and thats not the problem. im going to have to rework the Dynamicarray code all together.
|
|
#10
|
|||
|
|||
|
alright well it seems that the problem isnt a problem with code, if i leave the class declaration and implementation in a cpp file with main() it works fine, if i put the class deff and imp in a .h and include it that way, thats when it simply dosnt work, the program hangs, or during certain conditions ill get the glibc detected double free or corruption error.
anyone know why this is? |
|
#11
|
|||
|
|||
|
i am aware that when using templates that you must keep the definition and declaration in the same file, but as for what file it must be in i thought could be any.
|
|
#12
|
|||
|
|||
|
I dunno. If you can't track down exactly where the crash is happening, it'll be very hard to tell anything... can you compile it with the '-ggdb' flag, then run it like this:
Code:
gdb ./program gdb prompt> run crash error message gdb prompt> bt f full backtrace printout gdb prompt> quit Code:
#include <stdio.h>
...
fprintf(stderr,"printf example: c-str %s, int %i, ptr %p, float %f char %c\n",
"c-string", 42, (void *)(0xdeadbeef), 3.14159, 'q');
It also helps in debugging that fprintf is one single function call, while cout is as many function calls as there are << paramaters... Last edited by Corona688; 05-19-2006 at 10:56 PM. |
|
#13
|
|||
|
|||
|
*** glibc detected *** double free or corruption (top): 0x08ec9a48 ***
I'm a C++ beginner programmer. I'm using C++ on Unix with the gcc version 3.4.5 20051201 (Red Hat 3.4.5-2).
I have the same error message with my simulation program. When this error happens then the simulation stops running with the message "Abort". The simulation is supposed to run 50 replicates. This problem occurs randomly. Sometimes, it happened in the 32th and 37th replicates. Other time, it happened in the 3rd replicate. So, I tried to debug the program by running the program step by step. Surprisingly, the program ran fine. No error. Or when I tried to run the replicate that had this problem, then it ran fine, too. But not with 50 replicates in a row. My friend told me maybe it had something to do with optimization. I even lowered the level of optimization from -O to -O0. It didn't help. Could somebody educate me what is going on? Where should I look at? Many thanks. |
|
#14
|
|||
|
|||
|
youll have to post the code where the problem occurs, if you can determine where that is.
in my case, (i havent solved the problem yet) it seems like my system dosnt like templates in header files. my code runs fine with no problems if i have the class declared and implemented in the same file as main(). |
|||
| Google The UNIX and Linux Forums |