The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
install glibc-2.6.1 big123456 UNIX for Advanced & Expert Users 4 10-01-2007 01:46 AM
package glibc-2.3.2-95.27_x86.rpm big123456 Linux 1 01-24-2007 05:49 AM
extract glibc-2.3.2.tar.tar big123456 Linux 2 01-24-2007 02:33 AM
Updating glibc on a SuSE OpenExchange box cw1972 Linux 0 09-30-2003 03:25 AM
glibc 2.2.2 jurrien UNIX for Dummies Questions & Answers 1 03-07-2001 11:56 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-06-2008
Registered User
 

Join Date: May 2008
Posts: 23
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
glibc error

Hi All,

This is my first time posting on this forum. I'd like to
participate actively on this list.

Here we go!

I'm making a little application and I'm using ncurses. After a while
using it, I receive the following error and the stack trace is shown:

***glibc detected*** malloc() : memory corruption

Anybody knows when glibc throws this error??

I'll appreciate your help!

Thanks in advance!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-06-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,275
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
malloc is complaining that you have corrupted a pointer in some way example:
Code:
char *ptr=malloc(100);
char tmp[10={0x0};
..........
.......
ptr++;
............
..........
free(ptr);
The error happens on a realloc or a free because the pointer no longer references the same start of memory. You can get the same result by writing, say, 15 characters into the tmp string, so that you overwrote the string and changed the memory value stored in ptr.
Reply With Quote
  #3 (permalink)  
Old 05-06-2008
Registered User
 

Join Date: May 2008
Posts: 23
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Hi jim,

Thanks a lot for your answer, I'll re-check my code in order to find when malloc is trying to free up an incorrect memory address.
If I can't find the error, I'll post my code, because the error is thrown by a function of ncurses library. I think I'm passing a bad argument to this function.

Thank again!
Reply With Quote
  #4 (permalink)  
Old 05-06-2008
Registered User
 

Join Date: Dec 2007
Posts: 208
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
try add -Wall to your compile statement
Reply With Quote
  #5 (permalink)  
Old 05-07-2008
Registered User
 

Join Date: May 2008
Posts: 23
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Hi

Thanks frank, but I already have the -Wall flag in the Makefile.
Thaks!
Reply With Quote
  #6 (permalink)  
Old 05-07-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,275
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
There is also electric fence which can find buffer overruns for you.
Reply With Quote
  #7 (permalink)  
Old 05-07-2008
Registered User
 

Join Date: May 2008
Posts: 23
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Thanks

I've never used that kind of tool, but I'll try to use it in my application in order to find out what's happening.

Thanks!
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101