www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/01/27/03:58:39

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 <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "'Raf256' Rafal Maj" <raf256 AT szybkapoczta DOT pl>
cc: djgpp AT delorie DOT com
Subject: Re: SigSegV in new[]
In-Reply-To: <Xns91A39E5911F3rfdfciasdsdj412tr@213.180.128.20>
Message-ID: <Pine.SUN.3.91.1020127105615.14549M-100000@is>
MIME-Version: 1.0
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

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019