?
Solved

Invalid Address specified to RtlValidateHeap( 003A0000, 00E91F78 )

Posted on 2003-02-26
8
Medium Priority
?
5,841 Views
Last Modified: 2007-12-19
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
Comment
Question by:jjcao
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 

Author Comment

by:jjcao
ID: 8031675
jjcao@comgi.com
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8032345
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
 
LVL 22

Expert Comment

by:ambience
ID: 8032532
seems to be something wrong with fn3, but who knows, at-least post code for CIved constructor and destructor ...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:jjcao
ID: 8032718
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
 
LVL 49

Accepted Solution

by:
DanRollins earned 600 total points
ID: 8037713
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
 

Author Comment

by:jjcao
ID: 8040038
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
 

Author Comment

by:jjcao
ID: 8040062
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 8040300
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question