Wei,
    Thank you for the reply.

    Here are the projects:

VS 2005 Project
Is A
Uses Runtime Library
API project (provides my needed API into the FIPS Crypto++ DLL) Static library (lib)
Multi-threaded Debug (/MTd)
Small test program
Application (exe)
Multi-threaded Debug (/MTd)
Main program (replaces small test program)
Application (exe)
Multi-threaded Debug (/MTd)
wxWidgets
Static library (lib) Multi-threaded Debug (/MTd)
Crypto++ FIPS DLL
dll
??

    If I don't use Crypto++ the main program builds and runs just fine.  When I use Crypto++ with memory mgmt method 2, I get the heap failure.

    If there is no bug in the Crypto++ new and delete methods, then maybe wxWidgets uses the heap before the new and delete methods are reassigned.  Actually this is very likely because wxWidgets code runs before any of my application code.

    If that is the case, then the FIPS Crypto++ DLL can not be used with static libraries, in an application that uses wxWidgets. 

    I tried building everything with DLL libraries and using memory mgmt method 1.  This worked, but it caused several other problems for us.  It is not an acceptable solution for us.

    I really do not understand the need to reassign new and delete.  There are many dlls that allocate and free from the heap without doing this.

    In any event, I am in the process of moving my application to .NET, at which point we will not be using wxWidgets.  Can the FIPS DLL be used with .NET ?

    Paul

   


Wei Dai wrote:
You didn't say whether your API project is a DLL or static library. Same for wxWidgets. But anyway you apparently have 4 projects, and you have to either somehow make sure they all use the same memory heap, or if there is more than one heap, you never allocate from one heap and free it to another. One thing you can try is to trace into the new/delete calls and see if they do end up calling the same memory allocation/deallocation routines (use disassembly to check the function addresses).

And here is sample code for GetNewAndDeleteForCryptoPP, if you want to try that.

extern "C" __declspec(dllexport) void __cdecl GetNewAndDeleteForCryptoPP(PNew &pNew, PDelete &pDelete)
{
    pNew = &operator new;
    pDelete = &operator delete;
}

--------------------------------------------------
From: "Paul" <[EMAIL PROTECTED]>
Sent: Wednesday, October 24, 2007 9:23 AM
To: "Crypto++ Users" <[EMAIL PROTECTED]>
Subject: heap corruption


  I wrote a small set of methods (in a VS project) that calls the
FIPS DLL methods, to give me the API needed for my application.  I
wrote a small test program (in a separate VS project) that tests each
method, and everything is working.

  In my API project is the code for memory management, where Crypto++
tells my app what heap to use (Wei's method 2).  By the way, I
statically link with the Windows libraries.

  I then added my API project to my main solution.  This solution
uses, among other things, wxWidgets  During startup, I get a run time
error that the heap is corrupted.

  I see that several people have had this problem.  But I did not
find a solution in any of the email threads.  Is there a solution?

  I also tried running my test program with Purify.  This died before
the first executable line of my test program could run.

  While testing with my main solution, I noticed that wxWidgets had
done a ton of allocating and freeing of memory (new/delete) prior to
the corruption error.  It would seem that the FIPS DLL new/delete
methods have some bugs.

  Again, I ask, is there a solution?  I have read all of the related
threads on the Google email list.

  I would prefer not to dynamically link with the Windows libraries.
However if I were to try that, I could not find any example code of
using GetNewAndDeleteForCryptoPP (Wei's method 1).  I found one post
where the person asked for such an example and was never given one.






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to