Hi,
Are you freeing memory If this code is called inside a function. segmantion
fault means there are some buffer overflow. So please check your code and see
if allocated memory getting freed properly.
Regards,
Alok Kumar.
ed <[EMAIL PROTECTED]> wrote:
On Wed, 15 Nov 2006 20:10:29 -0000
"lul_hs" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I face a segmentation fault problem working with c++ under RedHat
> linux 9.0
> Sometimes it runs correctly and other time it gives a segmentation
> fault when the input is bigger(accesses).
>
> Here is some code segments.
>
> ....
> L1Cache= (int*)malloc(L1NumBlocks*a11*sizeof(unsigned int));
> L1FaCache= (int*)malloc(L1NumBlocks*2*sizeof(unsigned int));
> .
> .
> unsigned int *cold, *cCold;
> cold = new unsigned int(accesses);
> cout<<"thereee\n";
> cCold=cold;
> .
> .
> if(L1Cache[1+a11*L1Index]== L1Tag)
> {
> L1Hits++; hit=true; //cout<<" hit\n";
> continue; }
> else {
> bool c=false;
> int h=0;
> for( h=0;h<L1Cold ;h++)
> if(cCold[h]==L1Tag){c=true; mis++; }
> if(!c) { cold[L1Cold]=L1Tag; L1Cold++;
> }
>
> I woulg be greatfull if anyone can help me
i cant speak for everyone here, but theres not enough data there to
setup a test environment in our heads. i cannot see what some of those
values are initialised with.
try using a debugger and step through your code.
--
Regards, Ed :: http://www.openbsdhacker.com
proud unix hacker
Chuck Norris created a circle with corners.
---------------------------------
Sponsored Link
Mortgage rates near 39yr lows. $310,000 Mortgage for $999/mo - Calculate new
house payment