amd64 - strange behavior in simple C application - malloc() issue?
From: Ted Sung (teds_at_intex.com)
Date: 08/23/04
- Next message: Floyd L. Davidson: "Re: how to read 1 char from standard in?"
- Previous message: Moritz Franosch: "Re: g++ -Weffc++ -Wno-system-headers gives warnings in system headers nevertheless"
- Next in thread: Grant Edwards: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: Grant Edwards: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: Paul Pluzhnikov: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: Jens.Toerring_at_physik.fu-berlin.de: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: David Schwartz: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: QNils_O=2E_Sel=E5sdal=22?=: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Aug 2004 06:39:57 -0700
I don't understand why this is happening on This occurs on my AMD 64
machine, running SuSe Linux, GCC 3.2.2
Here are 2 simple C applications:
This program works -
#include <stdlib.h>
int main( void ) {
int * tmp = (int *)malloc( 131049 ) ;
free( (int*)tmp ) ;
exit 0 ;
}
This program FAILS with a core dump.
// #include <stdlib.h>
int main( void ) {
int * tmp = (int *)malloc( 131049 ) ;
free( (int*)tmp ) ;
exit 0 ;
}
I noticed that 131048 (=32762 4 byte units, suspiciously near 2^^15 =
32768) will WORK in the crashing version of the program.
It looks there is some default prototyping of malloc() when the
stdlib.h is not
included which is causing the free to crash the second program.
Any ideas?
Thanks,
Ted
- Next message: Floyd L. Davidson: "Re: how to read 1 char from standard in?"
- Previous message: Moritz Franosch: "Re: g++ -Weffc++ -Wno-system-headers gives warnings in system headers nevertheless"
- Next in thread: Grant Edwards: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: Grant Edwards: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: Paul Pluzhnikov: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: Jens.Toerring_at_physik.fu-berlin.de: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: David Schwartz: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Reply: QNils_O=2E_Sel=E5sdal=22?=: "Re: amd64 - strange behavior in simple C application - malloc() issue?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]