a strange debug error
-
I have created a dialog app, which return a debug error meesage that i don't understand. This message is: Debug error Program:D:\CalcRiskPort\Debug\CalcRiskPort.exe DAMAGE: after Normal block (#81) at 0x00301190 when i pree retry i have this message box: User breakpoint called from code at 0x1021376f you could see the following code concerned void CCalcRiskPortDlg::OnCalcvar() { UpdateData(TRUE); ::CoInitialize(NULL); //LoadTables Table; //LoadTables Table2(m_dlgSector); double *pTabVar=new double[(double)pow(2,m_dlgAsset)]; double *pTabMoy=new double[(double)pow(2,m_dlgAsset)]; CString *pTabPortStr=new CString[(long)pow(2,m_dlgAsset)]; CString strValue,strPortOpti,strMaxiSharpe,strMaxiEfficience; double MiniVar,MaxiSharpe,MaxiEfficience; int Rang; double *pMiniVar=new double[2]; //double *pMiniRatio=new double[2]; double *pMaxiRatioSharpe=new double[2]; double *pMaxiRatioEfficience=new double[2]; int *pTabBinPort=new int[m_dlgAsset]; int *pTabNumPort=new int[m_dlgAsset]; int k,i; try { LoadTables Table(1,m_dlgSector,1,m_dlgSector); _ConnectionPtr pConnection=NULL; CString strTemp; strTemp.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\CalcRiskPort\\Vol&CorrelDB.mdb;"); _bstr_t strCnn(strTemp); TESTHR(pConnection.CreateInstance(__uuidof(Connection))); pConnection->Open(strCnn,"","",adConnectUnspecified); Table.pCorrel=Table.LoadCorrelation(m_dlgSector,Table.pCorrel,"Correlation"); Table.pVol=Table.LoadVolatility(m_dlgSector,Table.pVol,"Volatilité"); Table.pYield=Table.LoadYield(m_dlgSector,Table.pYield,"Ratio"); i=0; for(k=0;k<=m_dlgAsset-1;k++) { *(pTabBinPort+k)=0; Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort); } *pTabVar=Table.CalcVar(pTabNumPort,m_dlgAsset); *pTabMoy=Table.CalcMoy(pTabNumPort,m_dlgAsset); Table.pRatioSharpe[0]=(*pTabMoy)/(*pTabVar); Table.pRatioEfficience[0]=((*pTabMoy+i)-m_dlgRate0)/(*pTabVar); *pTabPortStr=Table.AgregIntToStr(pTabNumPort,m_dlgAsset); for(i=1;i<=pow(2,m_dlgAsset)-1;i++) { k=m_dlgAsset-1; while(*(pTabBinPort+k)==1) { *(pTabBinPort+k)=0; Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort); if(k!=0) k--; } *(pTabBinPort+k)=1; Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort); *(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset); *(pTabMoy+i)=Table.CalcMoy(pTabNumPort,m_dlgAsset); Table.pRatioEfficience[i]=(*(pTabMoy+i))/(*(pTabVar+i)); Table.pRatioSharpe[i]=((*
-
I have created a dialog app, which return a debug error meesage that i don't understand. This message is: Debug error Program:D:\CalcRiskPort\Debug\CalcRiskPort.exe DAMAGE: after Normal block (#81) at 0x00301190 when i pree retry i have this message box: User breakpoint called from code at 0x1021376f you could see the following code concerned void CCalcRiskPortDlg::OnCalcvar() { UpdateData(TRUE); ::CoInitialize(NULL); //LoadTables Table; //LoadTables Table2(m_dlgSector); double *pTabVar=new double[(double)pow(2,m_dlgAsset)]; double *pTabMoy=new double[(double)pow(2,m_dlgAsset)]; CString *pTabPortStr=new CString[(long)pow(2,m_dlgAsset)]; CString strValue,strPortOpti,strMaxiSharpe,strMaxiEfficience; double MiniVar,MaxiSharpe,MaxiEfficience; int Rang; double *pMiniVar=new double[2]; //double *pMiniRatio=new double[2]; double *pMaxiRatioSharpe=new double[2]; double *pMaxiRatioEfficience=new double[2]; int *pTabBinPort=new int[m_dlgAsset]; int *pTabNumPort=new int[m_dlgAsset]; int k,i; try { LoadTables Table(1,m_dlgSector,1,m_dlgSector); _ConnectionPtr pConnection=NULL; CString strTemp; strTemp.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\CalcRiskPort\\Vol&CorrelDB.mdb;"); _bstr_t strCnn(strTemp); TESTHR(pConnection.CreateInstance(__uuidof(Connection))); pConnection->Open(strCnn,"","",adConnectUnspecified); Table.pCorrel=Table.LoadCorrelation(m_dlgSector,Table.pCorrel,"Correlation"); Table.pVol=Table.LoadVolatility(m_dlgSector,Table.pVol,"Volatilité"); Table.pYield=Table.LoadYield(m_dlgSector,Table.pYield,"Ratio"); i=0; for(k=0;k<=m_dlgAsset-1;k++) { *(pTabBinPort+k)=0; Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort); } *pTabVar=Table.CalcVar(pTabNumPort,m_dlgAsset); *pTabMoy=Table.CalcMoy(pTabNumPort,m_dlgAsset); Table.pRatioSharpe[0]=(*pTabMoy)/(*pTabVar); Table.pRatioEfficience[0]=((*pTabMoy+i)-m_dlgRate0)/(*pTabVar); *pTabPortStr=Table.AgregIntToStr(pTabNumPort,m_dlgAsset); for(i=1;i<=pow(2,m_dlgAsset)-1;i++) { k=m_dlgAsset-1; while(*(pTabBinPort+k)==1) { *(pTabBinPort+k)=0; Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort); if(k!=0) k--; } *(pTabBinPort+k)=1; Table.ConvertBinToNum(k,pTabBinPort,pTabNumPort); *(pTabVar+i)=Table.CalcVar(pTabNumPort,m_dlgAsset); *(pTabMoy+i)=Table.CalcMoy(pTabNumPort,m_dlgAsset); Table.pRatioEfficience[i]=(*(pTabMoy+i))/(*(pTabVar+i)); Table.pRatioSharpe[i]=((*
The error is most likely due to some out-of-bounds error: your code is trying to write beyond the limits of some of your arrays. When the assertion pops up, press "Retry" to get the debugger to the point where the error showed and use the "Call stack" window to determine which buffer is being overrun. This and a little research of your write operations will hopefully locate the error. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
The error is most likely due to some out-of-bounds error: your code is trying to write beyond the limits of some of your arrays. When the assertion pops up, press "Retry" to get the debugger to the point where the error showed and use the "Call stack" window to determine which buffer is being overrun. This and a little research of your write operations will hopefully locate the error. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
you were right, in fact i declare a wrong memory space for only one pointer that have to be deleted by the class destructor, but there was a problem as when i put value to this pointer, i did it in a for loop, in which i would like to put more that ten times memory spacxe than i have allocated. thanks a lot gerald