Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-01-2010, 10:37 AM   #1
LQ Newbie
Registered: Jul 2010
Posts: 5

Rep: Reputation: 0
C++ error glibc detected

Hi I am getting this error::

*** glibc detected *** ./a.out: free(): invalid next size (fast): 0x084ed538 ***
======= Backtrace: =========
======= Memory map: ========
0044f000-0046d000 r-xp 00000000 08:03 4571394 /lib/
0046d000-0046e000 r--p 0001d000 08:03 4571394 /lib/
0046e000-0046f000 rw-p 0001e000 08:03 4571394 /lib/
00471000-005e0000 r-xp 00000000 08:03 4571396 /lib/
005e0000-005e1000 ---p 0016f000 08:03 4571396 /lib/
005e1000-005e3000 r--p 0016f000 08:03 4571396 /lib/
005e3000-005e4000 rw-p 00171000 08:03 4571396 /lib/
005e4000-005e7000 rw-p 00000000 00:00 0
0060c000-00634000 r-xp 00000000 08:03 4571439 /lib/
00634000-00635000 r--p 00027000 08:03 4571439 /lib/
00635000-00636000 rw-p 00028000 08:03 4571439 /lib/
0063d000-0063e000 r-xp 00000000 00:00 0 [vdso]
00a70000-00a8d000 r-xp 00000000 08:03 4571447 /lib/
00a8d000-00a8e000 rw-p 0001c000 08:03 4571447 /lib/
00b3d000-00c1a000 r-xp 00000000 08:03 1452527 /usr/lib/
00c1a000-00c1e000 r--p 000dc000 08:03 1452527 /usr/lib/
00c1e000-00c20000 rw-p 000e0000 08:03 1452527 /usr/lib/
00c20000-00c26000 rw-p 00000000 00:00 0
08048000-08051000 r-xp 00000000 00:1b 2527430 /users/cs/grad/mladoia/a.out
08051000-08052000 rw-p 00008000 00:1b 2527430 /users/cs/grad/mladoia/a.out
084eb000-0850c000 rw-p 00000000 00:00 0 [heap]
b7707000-b7709000 rw-p 00000000 00:00 0
b772b000-b772e000 rw-p 00000000 00:00 0
bfeae000-bfec3000 rw-p 00000000 00:00 0 [stack]
Aborted (core dumped)

Note: I am not facing any problem during compilation.I am getting this error after my program runs successfully(i.e after the last line of my code is executed).

I am using vectors in my program:

when i am declaring value of that vector in my program:
vector< vector<double> > arr(50, vector<double>(50,0));
I am not getting this error.

But whenever I am assigning size of array dynamically
vector< vector<double> > arr;
Program compiles and runs fine but shows this error in the end.

Thank you in advance.
Old 07-01-2010, 10:57 AM   #2
LQ Guru
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
It means something has overwritten one of the chunks of data that malloc keeps in between the allocated chunks for keeping track of how big the chunks are and which are free.

Usually it means your program has written slightly beyond the end of some memory allocation and the error occurs when you try to free that allocation.

Originally Posted by mayankladoia View Post
vector< vector<double> > arr;
Assuming that is the object directly involved in the problem, you probably assign a value to an out of range element of arr. Ho do you use arr? Do you do anything equivalent to
arr[i][j] = something
If so, then I expect at some point j was greater than the value of x-1 as of the prior resize.
If the first subscript had been too large, it would point to something that isn't a vector and most likely seg fault right there. But if the second subscript were too large, it would just overwrite memory it doesn't own and most likely fail on a subsequent free() exactly as you're seeing.

But the assumption that arr is directly involved is just an assumption. You have a "memory clobber" bug and those are tricky. You seem to have found that a difference in the way you set the size of arr causes the bug to occur or not occur. That may make you conclude that arr is directly involved. But in many memory clobber bugs any change in any part of the program might hide the bug (make it symptom free). So look at arr first, because it is easier to check and has a decent chance to be the direct cause. But you might need some advanced gdb technique to find the real bug if it is actually somewhere else in your code.

Last edited by johnsfine; 07-01-2010 at 11:09 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
glibc detected error shibeaux Programming 1 05-13-2009 10:00 AM
*** glibc detected *** : error on my SuSE 10 box sunilvadranapu SUSE / openSUSE 1 02-20-2009 07:54 AM
Error: **** glibc detected **** nikekul Linux - Newbie 3 05-06-2008 03:01 AM
Error (IN NEW FORM) : *** glibc detected *** realloc() topworld Programming 6 04-29-2006 09:24 AM
Error::*** glibc detected *** realloc(): topworld Programming 2 04-26-2006 02:54 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration