Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5936
  • Last Modified:

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.
0
jjcao
Asked:
jjcao
  • 4
  • 3
1 Solution
 
jjcaoAuthor Commented:
jjcao@comgi.com
0
 
DanRollinsCommented:
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
0
 
ambienceCommented:
seems to be something wrong with fn3, but who knows, at-least post code for CIved constructor and destructor ...
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
jjcaoAuthor Commented:
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*>::iterator apos;
     vector<CNodeCtrl*>::iterator npos;
     for(apos=_arcs.begin();apos!=_arcs.end();++apos){
          if( *apos != NULL) delete (*apos);
     }
     for(npos=_nodes.begin();npos!=_nodes.end();++npos){
          if( *npos != NULL) delete (*npos);
     }
     _arcs.erase(_arcs.begin(),_arcs.end());
     _nodes.erase(_nodes.begin(),_nodes.end());
}
5. does not execute line4, the result is as same as before.
0
 
DanRollinsCommented:
I think you are hitting this well-known problem relating to using CSTL objects in a DLL:

    PRB: Access Violation When Accessing STL Object in DLL
    http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b172396

STL objects look like normal class objects, but they don't work the same.  STL is really just a complicated system of macros.  Each instantiation of an object has its own copy of the associated data.  So when the DLL allocates some new space, it is doing it in it's copy.

Some remedies are discussed here:

   HOWTO: Exporting STL Components Inside & Outside of a Class
   http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b168958

I've heard that some other (non MS) implementations of STL do not have this problem, but I'm unconvinced.

-- Dan
0
 
jjcaoAuthor Commented:
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.
0
 
jjcaoAuthor Commented:
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.
0
 
DanRollinsCommented:
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now