X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Date: Sun, 27 Jan 2002 10:56:56 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: "'Raf256' Rafal Maj" cc: djgpp AT delorie DOT com Subject: Re: SigSegV in new[] In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 26 Jan 2002, 'Raf256' Rafal Maj wrote: > I know that deleteing or free-ing invalid pointer may crash program > (SigSegV), but allocating memory ? Both malloc and free walk the heap data structures, so they both can crash if those data structures were corrupted by something. > My program crashes exacly in instruction : > > char * p = new char[l]; > > where l is an integer = 5 > > why ? this is not out-of-momoy problem... Does it means that I had done > something wrong with memory before and this effect appears later ? Probably. Either deallocating memory which wasn't allocated off the heap, or writing beyond the end of an allocated buffer, could produce such a crash. > Exiting due to signal SIGSEGV > General Protection Fault at eip=00055790 > eax=0000000a ebx=746f6f72 ecx=000baf58 edx=00000002 esi=00000054 edi=000c22e4 > ebp=00141318 esp=00141308 program=C:\UPT\SRC\UPT.EXE If you disassemble the program around 0x55790, the address where it crashed, I think you will find that it tries to dereference a pointer in the EBX register. The register dump above shows that the value of EBX looks like ASCII text ("root", written right to left, because x86 is a little endian machine). Does that "root" string ring a bell? Is there some code in your program where this string is used? If so, look there for a possible bug. See section 12.2 of the DJGPP FAQ for more hints about debugging similar problems.