LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-24-2010, 12:29 AM   #1
akhand_jyoti
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
C++ **glibc detected** ./a.out: munmap_chunk:invalid pointer


after giving the desired output ,above mentioned error comes with backtrace and memory map.
I use fedora 12.
 
Old 12-24-2010, 04:19 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,248

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
I just copied your subject line into google and got about 3,070 hits. It seems others have had that particular crash before . . .
 
Old 12-26-2010, 07:24 AM   #3
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
And we might be able to spot the problem slightly more easily if you gave us a (preferably small) sample of code which shows the problem and from the google hits, it seems likely that something is writing to memory it shouldn't be...
 
Old 12-26-2010, 07:49 AM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by akhand_jyoti View Post
after giving the desired output ,above mentioned error comes with backtrace and memory map.
I use fedora 12.
You should understand that this represents a bug in your program, not a bug in Fedora 12, nor in glibc, etc.

It appears that the bug is detected while the program is releasing resources after it has already produced its desired output. That doesn't mean the bug occurred at that point. Most likely the bug occurred significantly before the point at which it was detected.

Quote:
Originally Posted by business_kid View Post
It seems others have had that particular crash before . . .
That may be misleading help, especially as it may be misinterpreted to imply a Linux or glibc bug affecting many different people. That is not the case. Instead a lot of different beginning programmers have made many different mistakes, each of which was detected by glibc during release of some resource.

Unfortunately, the OP is not likely to find his bug by searching and reading other posts about other programmers whose different bugs produced the same error message.

Quote:
Originally Posted by Snark1994 View Post
And we might be able to spot the problem slightly more easily if you gave us a (preferably small) sample of code which shows the problem
If the code is small and the OP posts the whole thing, I'm sure the bug will be obvious to whatever experienced programmer looks at it first.

If the code is too large for the OP to post the whole thing, it is unlikely that the OP would guess the right portion to post to let us deduce the bug.

A very skilled programmer working on a much more difficult problem often can experimentally cut sections out of a program until a much smaller program shows the same symptom. That would be a good strategy if you actually thought a glibc or Linux bug was behind the symptom.

That isn't a great strategy for a beginner looking for an easy bug, because it would be far more work than finding the bug ought to be.

Quote:
it seems likely that something is writing to memory it shouldn't be...
I don't think there is any doubt of that. But that also doesn't narrow the possibilities much.

The most common and simplest bug with this symptom is writing past the end of an array allocated with malloc (or with new in C++). But after that common one, there are countless less common ones that taken together are more likely. So we can't really guess the bug without seeing it.

Last edited by johnsfine; 12-26-2010 at 08:04 AM.
 
Old 12-27-2010, 06:57 AM   #5
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
If the code is small and the OP posts the whole thing, I'm sure the bug will be obvious to whatever experienced programmer looks at it first.

If the code is too large for the OP to post the whole thing, it is unlikely that the OP would guess the right portion to post to let us deduce the bug.

A very skilled programmer working on a much more difficult problem often can experimentally cut sections out of a program until a much smaller program shows the same symptom. That would be a good strategy if you actually thought a glibc or Linux bug was behind the symptom.

That isn't a great strategy for a beginner looking for an easy bug, because it would be far more work than finding the bug ought to be.
Sorry, I obviously have lost sight of what people can do when starting out... I tend to do this to find problems in my own C code, then if I can't spot what I'm doing wrong in the smallest possible code sample then I post it here. We will just have to wait on the whole code, then
 
  


Reply


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
error : glibc detected invalid pointer rahulvishwakarma Programming 4 08-05-2010 10:58 AM
problem: *** glibc detected *** free(): invalid pointer: shashank929 Programming 2 04-16-2009 02:09 AM
Error during cimserver start : *** glibc detected *** realloc(): invalid pointer MaverickLikesMustang Linux - Software 0 02-14-2008 06:42 AM
glibc detected : Invalid Pointer Error DragonM15 Linux - Software 3 06-01-2007 12:43 AM
*** glibc detected *** free(): invalid pointer: 0x0804b094 *** lmvent Programming 4 02-03-2007 09:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:16 PM.

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