*** glibc detected ***

hello everybody :)
here is a little program, that saves vector to a file, and read file to a vector...
it seems, that all is okey, except one thing,,, after program end comes message:
*** glibc detected *** /home/aram/Dropbox/workspace/experimetlet/Debug/experimetlet: corrupted double-linked list: 0x00000000023b8100 ***

i am wondering why it happens...?!

please, if someone can, help me.

here is a link to cpp file.
http://dl.dropbox.com/u/53352759/eso.cpp

im using Ubuntu Linux, with kernel 3.2, gcc 4.6.3 and glibc 2.15
thanks.
Switch from passing pointers to vectors to passing vectors themselves, by reference.

As written, your readfile receives a pointer to a vector, obtains a reference to the vector with k[0], and then makes a pointer to that vector, reinterprets it as char*, and trashes memory with read.

What it should do is take the vector by reference, obtain a reference to its first element with k[0], obtain a pointer to that element, reinterpret it and read the array with read.

EDIT: also, int size1=sizeof(k) is wrong and should be int size1=k.size(); (after making k a reference)
Last edited on
BIG BIG BIG thank YOU Cubbi, its work, and you are the best !!!! :)
YOU have not hesitated to look my code, and you are great, thank you again.

nevertheless its my first program that doing that kind of things(mean working with files) and i still can not
understand why its work now, and why it didn't before ,,, hahaahahah :-D

maybe i will understand it later :-)
hey.
but some strange things still happening
wen trying to call after loading from file... for example vector_x[n].push_back(class_name(x,y,z))... program crashes :-(
why it can be...
also crash happens when trying to call vector_x[n].class_function().....
but before loading from file all works perfectly
IT IS STRANGE for me because
1. after loading vector from file, my program still can check some values from x_vector[n]...
it checks by loop whale x_vector, and if it find given ID(for example it at n-th element), then program checking its password, and if both are met it calls vector_x[n].menu();...
2. password check is another function in class_name... so, why all is ok while checking password with class function,
here it is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class User_Ordinary : public User_empty
{
public:
  User_Ordinary(std::string name, unsigned short int password, unsigned int money);

  //unsigned int get_user_cash();
  bool is_user_password_true(unsigned short int password);
  void menu();
private:

  void change_user_password();
  void check_user_balance();
  void cash_user_money();
  unsigned int user_money;
  unsigned short int user_password;
  unsigned int user_cash;
};



in another class User_ordinary used in declaring vector
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class User_ROOT : public User_empty
{
public:
  User_ROOT();

  void main_menu();
  void menu();

private:

  std::vector<User_Ordinary> users_database;
  std::vector<int> is_user_blocked;

};



so when we calling users_database[n].push_back(User_Ordinary("kuku", 1000, 0));
or users_database[n].menu();

program stops with crash :(
Last edited on
Topic archived. No new replies allowed.