SIGSEGV in new/malloc

Karthik J kartikj@geometricsoftware.com
Wed Sep 15 13:03:00 GMT 2004


Hi Eljay,

	Thanks for your response.
	
	Actually there are lots of succesfull calls to new/malloc,
before I run into this error.
	m_pData  is a member of a class, which essentially describes an
array of pointers( of any type, hence void** ). When I initially try to
set the size of the array( to some value that's nNewSize ), I allocate
memory to this array. That's when the crash occurs! 

	Compiler flags are -> -pipe -g -fPIC -Wall -Wno-reorder
	OS -> Solaris 8

	I am cutting out on all the voodoo for now and wrapping around a
std::vector< void* > instead:-).

	Thanks again.

-Kartik
	

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Eljay Love-Jensen
Sent: Wednesday, September 15, 2004 5:43 PM
To: Karthik J; gcc
Subject: Re: SIGSEGV in new/malloc

Hi Karthik,

Sorry, I could not get this to crash...
int main()
{
     typedef unsigned char BYTE;
     int nNewSize = 1;

     void** m_pData = (void**) new BYTE[nNewSize * sizeof(BYTE*)]; }

What compiler flags are you using?

What OS are you using?

Does your program do anything more than the above, or is this the
smallest program that reproduces the problem for you?

You could do this, by the way...
void** m_pData = new void*;
...cuts out some array voodoo magic sizing monkey business.  But that
shouldn't have any impact on your problem.  Just a coding style
suggestion.

--Eljay





More information about the Gcc-help mailing list