0xC00000FD: Stack overflow

vs2012报错:0xC00000FD: Stack overflow (参数: 0x00000001, 0x00AD2FFC)

出现栈溢出错误的原因:

1.在函数中同时申明了h和H数组,以为区分大小写,实际上是不区分大小写的,导致访问冲突,故去掉一个就可以了。

    int h[H_X][H_Y][H_Z];
    int H[HM_R][HM_C];

2. 其中涉及到申明的局部数组较大时,在占用内存空间较大的局部数组声明的前面加static将其从堆栈数据段挪到全局数据段即可。

如:static int last_h[H_X][H_Y][H_Z];

 

3. 崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处。

判断是否越界访问,可以在数组的最后一个元素之后对应的地址处设置数据读写断点。如果该地址对应其它变量干扰判断,可将数组多声明一个元素,并设置数据读写断点在该多出元素对应的地址上。

 

4.转自:https://blog.csdn.net/u013230291/article/details/78064167

计算机为一个进程所开辟的栈空间是一定的,当一个.cpp文件中的栈空间大于计算机为该进程所开发的栈空间时,就会报堆栈溢出错误。 

解决方案: 
基本是代码问题,这种bug比较隐形,只有在运行阶段才会发现,代码本身是可以编译通过的,但是进程中的某个函数中由于占用了过多的内存空间,导致出现这样的错误。更多是在处理大数据量,或者开辟大的内存空间时出现。正常情况下,注销一部分使用内存空间较多的代码即可运行通过了。解决的办法是多样的,要看你的具体代码,正常是将没有及时释放的内存及时释放掉,减小开辟的内存空间大小,将long类型的改为int或者char类型等方式。
--------------------- 
作者:姑苏王亦枫 
来源:CSDN 
原文:https://blog.csdn.net/u013230291/article/details/78064167 
版权声明:本文为博主原创文章,转载请附上博文链接!

 

 

展开阅读全文

栈溢出出问题。0xC00000FD:Stack Overflow

10-22

当我开始调试时,总是出现一个框显示:Unhandled exception in YUV.exe:0xC00000FD:Stack Overflowrn 好像是指针问题,内存释放的问题,可是不清楚怎么改啊???这个是VC6和opencv库函数一起编译的。rn#include rn#include rn#include rn#include rn#include rnusing namespace std;rn//void saturate_sv( IplImage* img);rnint main(int argc, char** argv[])rnint key=0;rnchar* filename="D:/002.avi";rnCvCapture* capture = cvCreateFileCapture(filename);rnif(capture==NULL) rncout<<"NO capture"<height ;y++)rn rn uchar*ptr=(uchar*)(frame->imageData+y*frame->widthStep);rn rn for (int x=0;xwidth;x++ )rn rn Y=(int)(0.299*ptr[3*x+2]+0.587*ptr[3*x+1]+0.144*ptr[3*x]); //ptr[3*x+2]得到Y分量每个像素点采集一个Y分量rn rn Cb=(int)(0.564*(ptr[3*x]-Y)+128);rn rn Cr=(int)(0.713*(ptr[3*x+2]-Y)+128);rnrn yy[i]=Y; cb1[b]=Cb; cr1[r]=Cr;rnrn i++; r++; b++; //ptr[3*x+2] 是R红色通道,ptr[3*x+1]是G绿色通道,ptr[3*x]是B蓝色通道。rn rn rnrn for (int k=0; k<76800; k++) //k的取值范围是0~76800rnrn for (int l=4*k; l<=4*k+3; l++) //l的取值范围是0~640*480=307200rnrn sum1+=cb1[b]; sum2+=cr1[r];rn rn rn avg1=(int)sum1/4; avg2=(int)sum2/4;rn rn cb2[k]=avg1; cr2[k]=avg2;rn rn sum1=0; sum2=0;rn rnrn FILE *file; rnrn file=fopen("d:\\file.yuv","ab");rn rn fwrite (yy,4,640*480,file); rn rn fwrite (cb2,4,76800,file); rn rn fwrite (cr2,4,76800,file); rn rn fclose (file); rn rncvShowImage("PlayAVI", frame );rnrnkey = cvWaitKey(33);// quit when users press 'ESC'rnrnif( key == 27 ) break;rnrnrnrncvReleaseCapture(&capture);rnrncvDestroyWindow("PlayAVI"); rnrnreturn 0;rnrn 论坛

求助:Unhandled exception in **.exe:0xC00000FD:Stack Overflow

10-13

[code=C/C++][/code]rndouble CSpaceResectionDlg::Function(double initXS,double initYS,double initZS,double initalfa,double initw,double initk)rnrn UpdateData();rn rn //initXS,initYS,initZS,initalfa,initw,initk的初始值rn initXS=(m_nXA+m_nXB+m_nXC+m_nXD)/4;rn initYS=(m_nYA+m_nYB+m_nYC+m_nYD)/4;rn initZS= m_nf*(1/m_nscale);rn initalfa=0.0;rn initw=0.0;rn initk=0.0;rnrn //以下是书上的公式rn double H = m_nf*(1/m_nscale);rnrn double a1 = cos(initalfa)*cos(initk)-sin(initalfa)*sin(initw)*sin(initk);rn double a2 = -cos(initalfa)*sin(initk)-sin(initalfa)*sin(initw)*cos(initk);rn double a3 = -sin(initalfa)*cos(initw);rnrn double b1 = cos(initw)*sin(initk);rn double b2 = cos(initw)*cos(initk);rn double b3 = -sin(initw);rnrn double c1 = sin(initalfa)*cos(initk)+cos(initalfa)*sin(initw)*sin(initk);rn double c2 = -sin(initalfa)*sin(initk)+cos(initalfa)*sin(initw)*sin(initk);rn double c3 = cos(initalfa)*cos(initw);rnrn double a11_1=1/(a3*(m_nXA-initXS)+b3*(m_nYA-initYS)+c3*(m_nZA-initZS))*(a1*m_nf+a3*m_nxa);rn double a12_1=1/(a3*(m_nXA-initXS)+b3*(m_nYA-initYS)+c3*(m_nZA-initZS))*(b1*m_nf+b3*m_nxa);rn double a13_1=1/(a3*(m_nXA-initXS)+b3*(m_nYA-initYS)+c3*(m_nZA-initZS))*(c1*m_nf+c3*m_nxa);rn double a21_1=1/(a3*(m_nXA-initXS)+b3*(m_nYA-initYS)+c3*(m_nZA-initZS))*(a2*m_nf+a3*m_nxa);rn double a22_1=1/(a3*(m_nXA-initXS)+b3*(m_nYA-initYS)+c3*(m_nZA-initZS))*(b2*m_nf+b3*m_nxa);rn double a23_1=1/(a3*(m_nXA-initXS)+b3*(m_nYA-initYS)+c3*(m_nZA-initZS))*(c2*m_nf+c3*m_nxa);rnrn double a14_1=m_nya*sin(initw)-(m_nxa/m_nf*(m_nxa*cos(initk)-m_nya*sin(initk))+m_nf*cos(initk))*cos(initw);rn double a15_1=-m_nf*sin(initk)-m_nxa/m_nf*(m_nxa*sin(initk)+m_nya*cos(initk));rn double a16_1=m_nya;rn double a24_1=-m_nxa*sin(initw)-(m_nya/m_nf*(m_nxa*cos(initk)-m_nya*sin(initk))-m_nf*sin(initk))*cos(initw);rn double a25_1=-m_nf*cos(initk)-m_nya/m_nf*(m_nxa*sin(initk)+m_nya*cos(initk));rn double a26_1=-m_nxa;rnrn double a11_2=1/(a3*(m_nXB-initXS)+b3*(m_nYB-initYS)+c3*(m_nZB-initZS))*(a1*m_nf+a3*m_nxb);rn double a12_2=1/(a3*(m_nXB-initXS)+b3*(m_nYB-initYS)+c3*(m_nZB-initZS))*(b1*m_nf+b3*m_nxb);rn double a13_2=1/(a3*(m_nXB-initXS)+b3*(m_nYB-initYS)+c3*(m_nZB-initZS))*(c1*m_nf+c3*m_nxb);rn double a21_2=1/(a3*(m_nXB-initXS)+b3*(m_nYB-initYS)+c3*(m_nZB-initZS))*(a2*m_nf+a3*m_nxb);rn double a22_2=1/(a3*(m_nXB-initXS)+b3*(m_nYB-initYS)+c3*(m_nZB-initZS))*(b2*m_nf+b3*m_nxb);rn double a23_2=1/(a3*(m_nXB-initXS)+b3*(m_nYB-initYS)+c3*(m_nZB-initZS))*(c2*m_nf+c3*m_nxb);rnrn double a14_2=m_nyb*sin(initw)-(m_nxb/m_nf*(m_nxb*cos(initk)-m_nyb*sin(initk))+m_nf*cos(initk))*cos(initw);rn double a15_2=-m_nf*sin(initk)-m_nxb/m_nf*(m_nxb*sin(initk)+m_nyb*cos(initk));rn double a16_2=m_nyb;rn double a24_2=-m_nxb*sin(initw)-(m_nyb/m_nf*(m_nxb*cos(initk)-m_nyb*sin(initk))-m_nf*sin(initk))*cos(initw);rn double a25_2=-m_nf*cos(initk)-m_nyb/m_nf*(m_nxb*sin(initk)+m_nyb*cos(initk));rn double a26_2=-m_nxb;rnrn double a11_3=1/(a3*(m_nXC-initXS)+b3*(m_nYC-initYS)+c3*(m_nZC-initZS))*(a1*m_nf+a3*m_nxc);rn double a12_3=1/(a3*(m_nXC-initXS)+b3*(m_nYC-initYS)+c3*(m_nZC-initZS))*(b1*m_nf+b3*m_nxc);rn double a13_3=1/(a3*(m_nXC-initXS)+b3*(m_nYC-initYS)+c3*(m_nZC-initZS))*(c1*m_nf+c3*m_nxc);rn double a21_3=1/(a3*(m_nXC-initXS)+b3*(m_nYC-initYS)+c3*(m_nZC-initZS))*(a2*m_nf+a3*m_nxc);rn double a22_3=1/(a3*(m_nXC-initXS)+b3*(m_nYC-initYS)+c3*(m_nZC-initZS))*(b2*m_nf+b3*m_nxc);rn double a23_3=1/(a3*(m_nXC-initXS)+b3*(m_nYC-initYS)+c3*(m_nZC-initZS))*(c2*m_nf+c3*m_nxc);rnrn double a14_3=m_nyc*sin(initw)-(m_nxc/m_nf*(m_nxc*cos(initk)-m_nyc*sin(initk))+m_nf*cos(initk))*cos(initw);rn double a15_3=-m_nf*sin(initk)-m_nxc/m_nf*(m_nxc*sin(initk)+m_nyc*cos(initk));rn double a16_3=m_nyc;rn double a24_3=-m_nxc*sin(initw)-(m_nyc/m_nf*(m_nxc*cos(initk)-m_nyc*sin(initk))-m_nf*sin(initk))*cos(initw);rn double a25_3=-m_nf*cos(initk)-m_nyc/m_nf*(m_nxc*sin(initk)+m_nyc*cos(initk));rn double a26_3=-m_nxc;rnrn rn double a11_4=1/(a3*(m_nXD-initXS)+b3*(m_nYD-initYS)+c3*(m_nZD-initZS))*(a1*m_nf+a3*m_nxd);rn double a12_4=1/(a3*(m_nXD-initXS)+b3*(m_nYD-initYS)+c3*(m_nZD-initZS))*(b1*m_nf+b3*m_nxd);rn double a13_4=1/(a3*(m_nXD-initXS)+b3*(m_nYD-initYS)+c3*(m_nZD-initZS))*(c1*m_nf+c3*m_nxd);rn double a21_4=1/(a3*(m_nXD-initXS)+b3*(m_nYD-initYS)+c3*(m_nZD-initZS))*(a2*m_nf+a3*m_nxd);rn double a22_4=1/(a3*(m_nXD-initXS)+b3*(m_nYD-initYS)+c3*(m_nZD-initZS))*(b2*m_nf+b3*m_nxd);rn double a23_4=1/(a3*(m_nXD-initXS)+b3*(m_nYD-initYS)+c3*(m_nZD-initZS))*(c2*m_nf+c3*m_nxd);rnrn double a14_4=m_nyd*sin(initw)-(m_nxd/m_nf*(m_nxd*cos(initk)-m_nyd*sin(initk))+m_nf*cos(initk))*cos(initw);rn double a15_4=-m_nf*sin(initk)-m_nxd/m_nf*(m_nxd*sin(initk)+m_nyd*cos(initk));rn double a16_4=m_nyd;rn double a24_4=-m_nxd*sin(initw)-(m_nyd/m_nf*(m_nxd*cos(initk)-m_nyd*sin(initk))-m_nf*sin(initk))*cos(initw);rn double a25_4=-m_nf*cos(initk)-m_nyd/m_nf*(m_nxd*sin(initk)+m_nyd*cos(initk));rn double a26_4=-m_nxd;rnrn //矩阵Arn double A[8][6]=rn a11_1,a12_1,a13_1,a14_1,a15_1,a16_1,rn a21_1,a22_1,a23_1,a24_1,a25_1,a26_1,rn a11_2,a12_2,a13_2,a14_2,a15_2,a16_2,rn a21_2,a22_2,a23_2,a24_2,a25_2,a26_2,rn a11_3,a12_3,a13_3,a14_3,a15_3,a16_3,rn a21_3,a22_3,a23_3,a24_3,a25_3,a26_3,rn a11_4,a12_4,a13_4,a14_4,a15_4,a16_4,rn a21_4,a22_4,a23_4,a24_4,a25_4,a26_4;rn rn //矩阵A的转置矩阵A_zhuanrn double A_zhuan[6][8]=rn a11_1,a21_1,a11_2,a21_2,a11_3,a21_3,a11_4,a21_4,rn a12_1,a22_1,a12_2,a22_2,a12_3,a22_3,a12_4,a22_4,rn a13_1,a23_1,a13_2,a23_2,a13_3,a23_3,a13_4,a23_4,rn a14_1,a24_1,a14_2,a24_2,a14_3,a24_3,a14_4,a24_4,rn a15_1,a25_1,a15_2,a25_2,a15_3,a25_3,a15_4,a25_4,rn a16_1,a26_1,a16_2,a26_2,a16_3,a26_3,a16_4,a26_4,rn ;rnrn rn double opprox_xa = -m_nf*(m_nXA-initXS)/(m_nZA-initZS);rn double opprox_ya = -m_nf*(m_nYA-initXS)/(m_nZA-initZS);rnrn double opprox_xb = -m_nf*(m_nXB-initXS)/(m_nZB-initZS);rn double opprox_yb = -m_nf*(m_nYB-initXS)/(m_nZB-initZS);rnrn double opprox_xc = -m_nf*(m_nXC-initXS)/(m_nZC-initZS);rn double opprox_yc = -m_nf*(m_nYC-initXS)/(m_nZC-initZS);rnrn double opprox_xd = -m_nf*(m_nXD-initXS)/(m_nZD-initZS);rn double opprox_yd = -m_nf*(m_nYD-initXS)/(m_nZD-initZS);rnrnrnrn double l_xa = m_nxa-opprox_xa;rn double l_ya = m_nya-opprox_ya;rnrn double l_xb = m_nxb-opprox_xb;rn double l_yb = m_nyb-opprox_yb;rnrn double l_xc = m_nxc-opprox_xc;rn double l_yc = m_nyc-opprox_yc;rnrn double l_xd = m_nxd-opprox_xd;rn double l_yd = m_nyd-opprox_yd;rnrnrn //矩阵Lrn double L[8][1]=l_xa,l_ya,l_xb,l_yb,l_xc,l_yc,l_xd,l_yd;rnrnrn //为矩阵A,A_zhuan,L,B,C,X分配内存 rn A[100][100];rn A_zhuan[100][100];rn L[100][100];rn double B[100][100];rn double C[100][100];rn double X[100][100];rn rn brmul((double*)A_zhuan,(double*)A,6,8,6,(double*)B);rn //矩阵A的转置矩阵乘以矩阵A,返回矩阵Brn brinv((double*)B,6);rn //矩阵B的逆rn brmul((double*)B,(double*)A_zhuan,6,6,8,(double*)C);rn //矩阵B的转置矩阵乘以矩阵A的转置矩阵,返回矩阵Crn brmul((double*)C,(double*)L,6,8,1,(double*)X);rn //矩阵C乘以矩阵L,返回矩阵Xrnrn rn //计算m_XS,m_YS,m_ZS,m_alfa,m_w,m_krn m_XS = initXS+X[0][0];rnrn m_YS = initYS+X[1][0];rnrn m_ZS = initZS+X[2][0];rnrn m_alfa=initalfa+X[3][0];rnrn m_w = initw+X[4][0];rnrn m_k = initk+X[5][0];rnrn rn //如果m_alfa或者m_w或者m_k的值大于0.1,rn if((fabs(m_alfa)>=0.1)||(fabs(m_w)>=0.1)||(fabs(m_k)>=0.1))rn rn initXS+=X[0][0];rn initYS+=X[1][0];rn initZS+=X[2][0];rn initalfa+=X[3][0];rn initw+=X[4][0];rn initk+=X[5][0];rn //递归rn Function(initXS,initYS,initZS,initalfa,initw,initk);rn return m_XS,m_YS,m_ZS,m_alfa,m_w,m_k;rn rn rn elsern return m_XS,m_YS,m_ZS,m_alfa,m_w,m_k;rnrn UpdateData(false);rnrn编译运行都没错,就是出不了结果rn我用断点看了看,提示:rnUnhandled exception in **.exe:0xC00000FD:Stack Overflowrn求助~~~~ 论坛

有未经处理的异常: 0xC00000FD: Stack overflow

04-25

程序运行时会出现 xxxx.exe 中的 0x00fa1c29 处有未经处理的异常: 0xC00000FD: Stack overflowrn这样的错误,中断一下,程序会指向下面这里:rn[img=http://img.my.csdn.net/uploads/201304/25/1366875560_1670.jpg][/img]rn下面是我的代码:rn[code=c]#include rn#include rn#include rnusing namespace std;rnrnrnint Find(int **a,int x,int y,int t)rnrn int count=0;rn if(x-1>=0&&x-1<332&&y>=0&&y<500&&a[x-1][y]==t)rn a[x-1][y]=-t;count++;count+=Find(a,x-1,y,t);rn if(x-1>=0&&x-1<332&&y+1>=0&&y+1<500&&a[x-1][y+1]==t)rn a[x-1][y+1]=-t;count++;count+=Find(a,x-1,y+1,t);rn if(x-1>=0&&x-1<332&&y-1>=0&&y-1<500&&a[x-1][y-1]==t)rn a[x-1][y-1]=-t;count++;count+=Find(a,x-1,y-1,t);rn if(x>=0&&x<332&&y+1>=0&&y+1<500&&a[x][y+1]==t)rn a[x][y+1]=-t;count++;count+=Find(a,x,y+1,t);rn if(x>=0&&x<332&&y-1>=0&&y-1<500&&a[x][y-1]==t)rn a[x][y-1]=-t;count++;count+=Find(a,x,y-1,t);rn if(x+1>=0&&x+1<332&&y>=0&&y<500&&a[x+1][y]==t)rn a[x+1][y]=-t;count++;count+=Find(a,x+1,y,t);rn if(x+1>=0&&x+1<332&&y+1>=0&&y+1<500&&a[x+1][y+1]==t)rn a[x+1][y+1]=-t;count++;count+=Find(a,x+1,y+1,t);rn if(x+1>=0&&x+1<332&&y-1>=0&&y-1<500&&a[x+1][y-1]==t)rn a[x+1][y-1]=-t;count++;count+=Find(a,x+1,y-1,t);rn return count;rnrnrnint main()rnrn int **s;rn s=new int*[332];rn for(int i=0;i<332;i++)rn s[i]=new int[500];rn rn int cnt[332][500]=0;rn ifstream fin;rn fin.open("d:\\data\\sc.txt");rn for(int i=0;i<332;i++)rn rn for(int j=0;j<500;j++)rn rn fin>>s[i][j];rn rn rn fin.close();rn for(int i=332;i<1;i++)rn rn for(int j=0;j<500;j++)rn rn cnt[i][j]=Find(s,i,j,s[i][j]);rn cout< 论坛

没有更多推荐了,返回首页