Glibc error, fail to open file

*** glibc detected *** a.out: double free or corruption (fasttop): 0x00000000016d62f0 ***
Set is a custom class.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Set readFile(Set In, char *name)
{
   ifstream fin;
   fin.open (name);
   cout << "Value of name in readFile:" << name << endl;
   if (fin.fail())
   {
      cerr << "failure to open" << endl;
      exit(0);
   }
   int temp = 0;
   fin >> temp;
   In.setMax(temp);
   int *point = new int[temp];
   In.setPointer(point);
   for (int i = 0, count = 0, junk = 0; i < In.getMax(); i++)
   {
      if(In.clone(In, point[i]))
      {
         fin >> point[i];
         count++;
      }
      else
      {
         fin >> junk;
      }
   }
   fin.close();
   return In;
}

1
2
3
4
5
6
7
8
9
10
int main(int argc, char **argv)
{
   Set A,B,C;
   char *inChar = argv[1];
   int inInt;
   cerr << "value of arg in main: " << argv[1]  << endl;
   readFile(A, inChar);
   cerr << "main second" << endl;
   inInt = A.getLength();
   readFile(B, argv[1], inInt);



output:
a.out assign_test2.cpp
1
2
3
4
5
6
7
value of arg in main: assign_test2.in
Value of name in readFile: assign_test2.in
*** glibc detected *** a.out: double free or corruption (fasttop): 0x00000000012ac2f0 ***

Bunch of seemingly random numbers:

Aborted (core dumped)

I hope this is sufficient. I posted the relevant areas for the problem. Let me know if you need more of the code and thank you.
Last edited on
Why don't you try to debug it and find where the error is occurring?
I debugged it and got a System.AccessViolationException. Any ideas?
Topic archived. No new replies allowed.