public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* STRANGE GLibC Problems
@ 2006-03-07 16:06 Mike McWilliam
  2006-03-07 16:55 ` Brian Budge
  0 siblings, 1 reply; 4+ messages in thread
From: Mike McWilliam @ 2006-03-07 16:06 UTC (permalink / raw)
  To: gcc-help

Hello There

         I have some problems with some C++ code and the g++ compiler.
I have two Suse Linux machines running on two different computers let
me give you the info for each one

Machine One
--------------------------
OS:               SuSE 10.0
Arcitecture:     AMD Athlon 64 2200
RAM:             512 MB
Motherboard:  Asus K8E SE
G++ Version: 4.0.2
GNU GLibC:   2.3.5-40

Machine Two
--------------------------
OS:               SuSE 10.0
Arcitecture:     Intel Pentium IV 2.4 GHz
RAM:             512 MB
Motherboard:  ???
G++ Version:  4.0.2
GNU GLibC:   2.3.5-40

         Identical SW platform, however one uses the 64 bt
architecture. So some HW differences. Now the problem was that the
Code was developed on Machine one and ran with no problems. However
when it is ran on machine Two I get the following error very early in
the code:

*** glibc detected *** free(): invalid next size (normal): 0x080da638 ***
Aborted

         I can't seem to find the offending pointer 0x080da638. Memory
leaks and array out of bound errors should not be there since it
worked on Machine One. I've combed through my code several times to
find something. Yet I get nothing. Could you help me out on where I
can go to solve this problem. I would like code from machine one to
work on machine two for obvious reasons. Thanks for any help you have
to offer.

Mike

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: STRANGE GLibC Problems
  2006-03-07 16:06 STRANGE GLibC Problems Mike McWilliam
@ 2006-03-07 16:55 ` Brian Budge
  2006-03-08  6:36   ` Digvijoy Chatterjee
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Budge @ 2006-03-07 16:55 UTC (permalink / raw)
  To: Mike McWilliam; +Cc: gcc-help

Hi Mike -

Memory problems can definitely be strange.  This is because it can be
the case that your mistake and the error can seem to have very little
in common either spatially and/or temporally.

I suggest you look for any cases where you might possibly be
overrunning an array or accessing memory outide of a structure, etc...
 What happens is that malloc returns a chunk of memory with special
data at the front of it, so that when free is called, free can delete
the appropriate memory.

It seems like what may have happened is that this special chunk has
been trampled, so it doesn't agree with what glibc thinks it should
be.

Good luck!  Memory is hard to debug :(

  Brian

On 3/7/06, Mike McWilliam <pilot.mm@gmail.com> wrote:
> Hello There
>
>          I have some problems with some C++ code and the g++ compiler.
> I have two Suse Linux machines running on two different computers let
> me give you the info for each one
>
> Machine One
> --------------------------
> OS:               SuSE 10.0
> Arcitecture:     AMD Athlon 64 2200
> RAM:             512 MB
> Motherboard:  Asus K8E SE
> G++ Version: 4.0.2
> GNU GLibC:   2.3.5-40
>
> Machine Two
> --------------------------
> OS:               SuSE 10.0
> Arcitecture:     Intel Pentium IV 2.4 GHz
> RAM:             512 MB
> Motherboard:  ???
> G++ Version:  4.0.2
> GNU GLibC:   2.3.5-40
>
>          Identical SW platform, however one uses the 64 bt
> architecture. So some HW differences. Now the problem was that the
> Code was developed on Machine one and ran with no problems. However
> when it is ran on machine Two I get the following error very early in
> the code:
>
> *** glibc detected *** free(): invalid next size (normal): 0x080da638 ***
> Aborted
>
>          I can't seem to find the offending pointer 0x080da638. Memory
> leaks and array out of bound errors should not be there since it
> worked on Machine One. I've combed through my code several times to
> find something. Yet I get nothing. Could you help me out on where I
> can go to solve this problem. I would like code from machine one to
> work on machine two for obvious reasons. Thanks for any help you have
> to offer.
>
> Mike
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: STRANGE GLibC Problems
  2006-03-07 16:55 ` Brian Budge
@ 2006-03-08  6:36   ` Digvijoy Chatterjee
  2006-03-08 14:03     ` Jim Stapleton
  0 siblings, 1 reply; 4+ messages in thread
From: Digvijoy Chatterjee @ 2006-03-08  6:36 UTC (permalink / raw)
  To: Brian Budge; +Cc: Mike McWilliam, gcc-help


I had a similar problem once ,and valgrind is worth a try , if Mike
hasn't done it already.

-- 
Thanks and Regards
Digvijoy Chatterjee


On Tue, 2006-03-07 at 08:55 -0800, Brian Budge wrote:
> Hi Mike -
> 
> Memory problems can definitely be strange.  This is because it can be
> the case that your mistake and the error can seem to have very little
> in common either spatially and/or temporally.
> 
> I suggest you look for any cases where you might possibly be
> overrunning an array or accessing memory outide of a structure, etc...
>  What happens is that malloc returns a chunk of memory with special
> data at the front of it, so that when free is called, free can delete
> the appropriate memory.
> 
> It seems like what may have happened is that this special chunk has
> been trampled, so it doesn't agree with what glibc thinks it should
> be.
> 
> Good luck!  Memory is hard to debug :(
> 
>   Brian
> 
> On 3/7/06, Mike McWilliam <pilot.mm@gmail.com> wrote:
> > Hello There
> >
> >          I have some problems with some C++ code and the g++ compiler.
> > I have two Suse Linux machines running on two different computers let
> > me give you the info for each one
> >
> > Machine One
> > --------------------------
> > OS:               SuSE 10.0
> > Arcitecture:     AMD Athlon 64 2200
> > RAM:             512 MB
> > Motherboard:  Asus K8E SE
> > G++ Version: 4.0.2
> > GNU GLibC:   2.3.5-40
> >
> > Machine Two
> > --------------------------
> > OS:               SuSE 10.0
> > Arcitecture:     Intel Pentium IV 2.4 GHz
> > RAM:             512 MB
> > Motherboard:  ???
> > G++ Version:  4.0.2
> > GNU GLibC:   2.3.5-40
> >
> >          Identical SW platform, however one uses the 64 bt
> > architecture. So some HW differences. Now the problem was that the
> > Code was developed on Machine one and ran with no problems. However
> > when it is ran on machine Two I get the following error very early in
> > the code:
> >
> > *** glibc detected *** free(): invalid next size (normal): 0x080da638 ***
> > Aborted
> >
> >          I can't seem to find the offending pointer 0x080da638. Memory
> > leaks and array out of bound errors should not be there since it
> > worked on Machine One. I've combed through my code several times to
> > find something. Yet I get nothing. Could you help me out on where I
> > can go to solve this problem. I would like code from machine one to
> > work on machine two for obvious reasons. Thanks for any help you have
> > to offer.
> >
> > Mike
> >



**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: STRANGE GLibC Problems
  2006-03-08  6:36   ` Digvijoy Chatterjee
@ 2006-03-08 14:03     ` Jim Stapleton
  0 siblings, 0 replies; 4+ messages in thread
From: Jim Stapleton @ 2006-03-08 14:03 UTC (permalink / raw)
  To: gcc-help

If you don't want to learn a new utility, something I like to do in
situations like this, is rather than using malloc/realloc straight I
use the macros below. Actually, I just used this on monday to find why
I was getting the error you got. Turns out it was the pointer had been
moved away from the initial allocated space and into the middle of the
array that I had allocated, and I didn't take that into account before
I called free().

#ifdef DEBUG_MEMORY
#include <stdio.h>

#define malloc_info( Y, X ) \
  (Y) = malloc(X);
  fprintf(stderr, "Memory allocated at position 0x%08X @ %s :: %d\n",
(Y), __FILE__, __LINE__);
#endif

#define realloc_info( X, Y, X ) \
  (X) = realloc(Y, X);
  fprintf(stderr, "Memory reallocation at position 0x%08X (now at
position 0x%08X) @ %s :: %d\n", (Y), (X), __FILE__, __LINE__);
#endif

#define free_info( X ) \
  fprintf(stderr, "Memory freed at position 0x%08X @ %s :: %d\n", (X),
__FILE__, __LINE__);
  free(X);
#endif

#else

#define malloc_info( Y, X ) \
  (Y) = malloc(X);
#endif

#define realloc_info( X, Y, X ) \
  (X) = realloc(Y, X);
#endif

#define free_info( X ) \
  free(X);
#endif

#endif



However, in larger programs, this could be quite a nightmare with lots
of output, or if you cannot use console IO on your program. A friend
of mine strongly recommends that valgrind environment, so I suspect it
is strongly worth looking into.

-Jim

On 3/8/06, Digvijoy Chatterjee <digvijoy_chatterjee@infosys.com> wrote:
>
> I had a similar problem once ,and valgrind is worth a try , if Mike
> hasn't done it already.
>
> --
> Thanks and Regards
> Digvijoy Chatterjee
>
>
> On Tue, 2006-03-07 at 08:55 -0800, Brian Budge wrote:
> > Hi Mike -
> >
> > Memory problems can definitely be strange.  This is because it can be
> > the case that your mistake and the error can seem to have very little
> > in common either spatially and/or temporally.
> >
> > I suggest you look for any cases where you might possibly be
> > overrunning an array or accessing memory outide of a structure, etc...
> >  What happens is that malloc returns a chunk of memory with special
> > data at the front of it, so that when free is called, free can delete
> > the appropriate memory.
> >
> > It seems like what may have happened is that this special chunk has
> > been trampled, so it doesn't agree with what glibc thinks it should
> > be.
> >
> > Good luck!  Memory is hard to debug :(
> >
> >   Brian
> >
> > On 3/7/06, Mike McWilliam <pilot.mm@gmail.com> wrote:
> > > Hello There
> > >
> > >          I have some problems with some C++ code and the g++ compiler.
> > > I have two Suse Linux machines running on two different computers let
> > > me give you the info for each one
> > >
> > > Machine One
> > > --------------------------
> > > OS:               SuSE 10.0
> > > Arcitecture:     AMD Athlon 64 2200
> > > RAM:             512 MB
> > > Motherboard:  Asus K8E SE
> > > G++ Version: 4.0.2
> > > GNU GLibC:   2.3.5-40
> > >
> > > Machine Two
> > > --------------------------
> > > OS:               SuSE 10.0
> > > Arcitecture:     Intel Pentium IV 2.4 GHz
> > > RAM:             512 MB
> > > Motherboard:  ???
> > > G++ Version:  4.0.2
> > > GNU GLibC:   2.3.5-40
> > >
> > >          Identical SW platform, however one uses the 64 bt
> > > architecture. So some HW differences. Now the problem was that the
> > > Code was developed on Machine one and ran with no problems. However
> > > when it is ran on machine Two I get the following error very early in
> > > the code:
> > >
> > > *** glibc detected *** free(): invalid next size (normal): 0x080da638 ***
> > > Aborted
> > >
> > >          I can't seem to find the offending pointer 0x080da638. Memory
> > > leaks and array out of bound errors should not be there since it
> > > worked on Machine One. I've combed through my code several times to
> > > find something. Yet I get nothing. Could you help me out on where I
> > > can go to solve this problem. I would like code from machine one to
> > > work on machine two for obvious reasons. Thanks for any help you have
> > > to offer.
> > >
> > > Mike
> > >
>
>
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-03-08 14:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-07 16:06 STRANGE GLibC Problems Mike McWilliam
2006-03-07 16:55 ` Brian Budge
2006-03-08  6:36   ` Digvijoy Chatterjee
2006-03-08 14:03     ` Jim Stapleton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).