I wrote a program with g ++, and one of them is
For (I = 0; I <5; I ++)
Push_back ();
This code has been called N times. When it is called for a certain number of times, the above error is reported when it is executed to push_back. Use gdb to read it one by one and finally enter malloc. c. the following error is returned:
Malloc. c: 3096: sYSMALLOc: Assertion '(old_top = (mbinptr) (char *) & (av)-> bins [(1)-1) * 2])-_ builtin_offsetof (struct malloc_chunk, fd) & old_size = 0) | (unsigned long) (old_size)> = (unsigned long) (_ builtin_offsetof (struct malloc_chunk, fd_nextsize) + (2 * (sizeof (size_t)-1 ))&~ (2 * (sizeof (size_t)-1) & (old_top)-> size & 0x1) & (unsigned long) old_end & pagemask) = 0) 'failed.
Aborted
Initially, it was suspected that the memory was leaking. on the Internet, it was said that the heap space was insufficient.
Debugging for half a day, no result, it is best to compare with the previous program, find the cause of the error in
I like to disable memory alignment when defining struct.
# Pramga pack (push, 1)
... Define struct
# Pargma pack (pop) // you have forgotten this sentence
The next thing happened.
From ma100's column