jjcao
asked on
Invalid Address specified to RtlValidateHeap( 003A0000, 00E91F78 )
There is a exe and a dll. 'CIved' is a class in exe.
'ITER()' and 'IVEDClear()' are functions in dll. 'ITER()' allocate some memory and 'IVEDClear()' clear memory allocated by 'ITER()'.
When the codes are:
for(int i=0; i<fn1n.size(); ++i){
CIved cived;
line1: ITER(fn1n[i],fn2n[i],fn3, logfile);
line2: IVEDClear();
line3: cived.import(fn1[i], fn3);
line4 : cived.export(fn1n[i]);
}
Everything is OK.
But after I moved line1 and line2 below line3 and line4, I meet an error given by MS viual c++ 6.0 when destruction function of CIved is execute:
HEAP[IVED_0_1.exe]: Invalid Address specified to RtlValidateHeap( 003A0000, 00E91F78 )
The codes are:
for(int i=0; i<fn1n.size(); ++i){
CIved cived;
line3: cived.import(fn1[i], fn3);
line4 : cived.export(fn1n[i]);
line1: ITER(fn1n[i],fn2n[i],fn3, logfile);
line2: IVEDClear();
}
Could anyone give me some hint? The project is urgent, and Im wishing for your help.
Thanks very much for your attention.
'ITER()' and 'IVEDClear()' are functions in dll. 'ITER()' allocate some memory and 'IVEDClear()' clear memory allocated by 'ITER()'.
When the codes are:
for(int i=0; i<fn1n.size(); ++i){
CIved cived;
line1: ITER(fn1n[i],fn2n[i],fn3, logfile);
line2: IVEDClear();
line3: cived.import(fn1[i], fn3);
line4 : cived.export(fn1n[i]);
}
Everything is OK.
But after I moved line1 and line2 below line3 and line4, I meet an error given by MS viual c++ 6.0 when destruction function of CIved is execute:
HEAP[IVED_0_1.exe]: Invalid Address specified to RtlValidateHeap( 003A0000, 00E91F78 )
The codes are:
for(int i=0; i<fn1n.size(); ++i){
CIved cived;
line3: cived.import(fn1[i], fn3);
line4 : cived.export(fn1n[i]);
line1: ITER(fn1n[i],fn2n[i],fn3, logfile);
line2: IVEDClear();
}
Could anyone give me some hint? The project is urgent, and Im wishing for your help.
Thanks very much for your attention.
1) What kind of objects are fn1n[i] and fn2n[i] and fn3
2) What does ITER() do? Does it modify fn1n[i], fn2n[i] and/or fn3?
3) What do cived.import and cived.export do?
4) what does the cived destructor do?
It is quite urgent that you answer these question because otherwise, your urgent problem cannot be solved.
-- Dan
2) What does ITER() do? Does it modify fn1n[i], fn2n[i] and/or fn3?
3) What do cived.import and cived.export do?
4) what does the cived destructor do?
It is quite urgent that you answer these question because otherwise, your urgent problem cannot be solved.
-- Dan
seems to be something wrong with fn3, but who knows, at-least post code for CIved constructor and destructor ...
ASKER
Further info:(using namespace std;)
1. IVEDDLL_API int ITER(const string fn1, const string fn2, const string fn3, const string logname, const int operateType=0); // function in ived.dll
2. vector<string> fn1n[i], fn2n[i]; string fn3; // variables in ived.exe
3. void CIved::import (const string fn, const string f3, const filetype ft){ //a member function of CIved,
//in ived.exe
string name;
name = gname;// char gname[5], gcation[5]; variables in ived.dll
name += gcatiopn;
…//get lots of variables of int, double, char [5] from ived.dll
}
4. CIved::~CIved() call void CIved::clear();
void CIved::clear(){
if(_mainCtrl!=NULL) delete _mainCtrl;
if(_output!=NULL) delete _output;
vector<CArcCtrl*>::iterato r apos;
vector<CNodeCtrl*>::iterat or npos;
for(apos=_arcs.begin();apo s!=_arcs.e nd();++apo s){
if( *apos != NULL) delete (*apos);
}
for(npos=_nodes.begin();np os!=_nodes .end();++n pos){
if( *npos != NULL) delete (*npos);
}
_arcs.erase(_arcs.begin(), _arcs.end( ));
_nodes.erase(_nodes.begin( ),_nodes.e nd());
}
5. does not execute line4, the result is as same as before.
1. IVEDDLL_API int ITER(const string fn1, const string fn2, const string fn3, const string logname, const int operateType=0); // function in ived.dll
2. vector<string> fn1n[i], fn2n[i]; string fn3; // variables in ived.exe
3. void CIved::import (const string fn, const string f3, const filetype ft){ //a member function of CIved,
//in ived.exe
string name;
name = gname;// char gname[5], gcation[5]; variables in ived.dll
name += gcatiopn;
…//get lots of variables of int, double, char [5] from ived.dll
}
4. CIved::~CIved() call void CIved::clear();
void CIved::clear(){
if(_mainCtrl!=NULL) delete _mainCtrl;
if(_output!=NULL) delete _output;
vector<CArcCtrl*>::iterato
vector<CNodeCtrl*>::iterat
for(apos=_arcs.begin();apo
if( *apos != NULL) delete (*apos);
}
for(npos=_nodes.begin();np
if( *npos != NULL) delete (*npos);
}
_arcs.erase(_arcs.begin(),
_nodes.erase(_nodes.begin(
}
5. does not execute line4, the result is as same as before.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dear DanRollins,
I've not use any point of reference of any STL object. I only export several STL objects from a WIN32 dll not surpporting MFC, such as string, and vecotr< vector< string> >. And I use string as parameter in functions called by different process. I also export much of ordinary variables.
I'm not understand the question well until now. But your hint is useful. And I solve the problem by change two dll called by my exe from win32 dll to MFC dll. Now, I run the for cycle again and again, nothing happens.
Do you have any other suggestion? For further info, I give you(DanRollins) 50 first.
I've not use any point of reference of any STL object. I only export several STL objects from a WIN32 dll not surpporting MFC, such as string, and vecotr< vector< string> >. And I use string as parameter in functions called by different process. I also export much of ordinary variables.
I'm not understand the question well until now. But your hint is useful. And I solve the problem by change two dll called by my exe from win32 dll to MFC dll. Now, I run the for cycle again and again, nothing happens.
Do you have any other suggestion? For further info, I give you(DanRollins) 50 first.
ASKER
Sorry for I do not konw giving points will close the question. I do not want to close the question now. So wait a while, please. And thanks for your help.
STL objects such as vecotr< vector< string> > can cause the problems described in that link.
If you switch to MFC you might also consider switching to MFC's CString class (it is VERY nice to work with) and MFC cah collection classes, such as CList and CStringArray and CPtrArray, etc.
=-=-=-=-=-=-=-=-
If you want to give 50 pts to me, do this: Create a new question and title it "Points for DanRollins" In the question text, say:
For help in Q_20531605
I will then post a comment in that question and you can accept it as an answer to that question.
-- Dan
If you switch to MFC you might also consider switching to MFC's CString class (it is VERY nice to work with) and MFC cah collection classes, such as CList and CStringArray and CPtrArray, etc.
=-=-=-=-=-=-=-=-
If you want to give 50 pts to me, do this: Create a new question and title it "Points for DanRollins" In the question text, say:
For help in Q_20531605
I will then post a comment in that question and you can accept it as an answer to that question.
-- Dan
ASKER