This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: GCC untrackable crashes


On Wed, 21 Feb 2001, Kevin Camera wrote:

> I was recommended to add more details about this problem (the seg fault
> within __size_of_stack_reserve).  I was hesitant to do this because the code
> seems to be pretty standard and works on all other machines.

Kevin, You may be running into Cygwin or gcc bugs, and then again you may
be running into bugs in your code. There is *no* way to tell without a
working testcase, which means a complete program that we can run and test.

Is there any way you can put these two in a complete program?

There is one other issue I can see right away.

> 	if ( currentState->entry != NULL ) {
> 	    // Allocate a new string buffer
> 	    length += strlen(currentState->entry);
> 	    tmpbuf = new char[length];
                             ^^^^^^^^ [length + 1]
> 	    // Copy in the new code and add the old at the end
> 	    strcpy(tmpbuf,currentState->entry);
> 	    strcat(tmpbuf,entrybuf);
            ^^^^^^^^^^^^^^^^^^^^^^^^ 
	    But you don't have enough room for this!


Here's what I suggest -- use a memory debugger say on Linux or Solaris
(ElectricFence works very well on both), and see what you find first.

All those character strings could be very easily be replaced with
std::string and memory trampling/leak issues go away.

FYI, there is an obvious bug in your ofstream code that will trip you up,
especially using some of the newer compilers with (almost) standard C++
library -- since you're reusing the same stream, you need to do a 
outfile.clear() before each open. It's not relevant here, since that 
particular problem will be caught by your code.

Regards,
Mumit



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]