The program is a bit too big to put here, and Im unable to replicate a simple
Yes, I am using GDB to step through it, but it doesnt give much info apart
from ??() errors, so thats no good. Incidentally, I did step upon something
which suggested to me it might be a problem using std::Vector<>, since the
crash seems to happen there. I am suspecting something troublemsome with
STLport version of it.
Any idea why some variables might cause a corrupt stack?
Luke Dunstan wrote:
> ----- Original Message -----
> From: "kmittal" <kmittal82@...>
> To: <mingw-users@...>
> Sent: Wednesday, January 31, 2007 2:02 AM
> Subject: [Mingw-users] Strange Crash with MinGW and STLport
>> I am compiling a program with MinGW (3.4.2), using STLPort libraries
>> (5.1.0). The program deals with strings and streams, and as far as my
>> understanding goes, GCC 3.4 , STLPOrt and strings dont really go very
>> Anyways, I am experiencing some of the strangest crash I have ever seen
>> running my executable. Unfrotunatley the files are too big to list here,
>> I will try and explain in simple terms.
>> My header files declares lots of variables, all of different sorts, but
>> mostly of type unsigned char *. Now, when I run my program after
>> the program seems to crash. Using GDB, I narrow it down to a crash on the
>> destructor, where a particular variable is delted (by calling delete ).
>> have made sure that the variable is checked for NULL before calling
>> on it. Besides, the variable also has a valid value in it when checked
>> through GDB.
>> Also, I get a warning about invalid address being passed to RTlheap.
>> Now, to stop the crash, all I do is put the declaration of the variable
>> different line number, and that does the job. So, in context, if I
>> unsigned char * a;
>> unsigned char *b;
>> The program crashes. But If i Do
>> unsigned char * b;
>> unsigned chat * a;
>> The program runs fine.
>> Another strange anomaly here is that if I DO want to keep the order of
>> variables same and not get the program to crash, all I need to do is
>> a dummy vraible, of any type (int, char etc..), adn then it seems to work
>> ok. I dont even need to use the variable, or initialise it.
> This sort of behaviour is not unusual. Typically you have a bug that
> part of the stack to be corrupted, and changing your variable declarations
> can change the placement of objects on the stack so that the crash can be
> accidentally avoided or hidden. Have you tried using GDB to step through
> your code? Unfortunately I doubt anyone will be able to help unless you
> a complete program that demonstrates the crash.
>> Since this is a porting effort, I am not at much liberty to change
>> unless necessary, and just wonderign if anyone has an idea about this? My
>> guess is either the stack is getting messed up, or the variable is not
>> initialised, but then again, why would it work when it is re-ordered at
>> Another thing I noted when debugging with GDB was that the program
>> on a incremenring a vector i.e.
>> std::vector<char*>::iterator aPos;
>> char *aPtr;
>> aPos = cleanupStack.begin();
>> while( aPos != cleanupStack.end() )
>> aPtr = *aPos;
>> delete  aPtr;
>> The crash happens at aPos++.
>> The STLPort library has been built with the install-dbg-static option,
>> is statically linked against the application
>> Thanks in advance.
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> opinions on IT & business topics through brief surveys - and earn cash
> MinGW-users mailing list
> You may change your MinGW Account Options or unsubscribe at:
View this message in context: http://www.nabble.com/Strange-Crash-with-MinGW-and-STLport-tf3143498.html#a8730829
Sent from the MinGW - User mailing list archive at Nabble.com.