MAPI crashes when MAPIUninitialize() is called

Dec 4, 2009 at 10:47 AM
Edited Dec 4, 2009 at 11:33 AM


i have created an application which logs in to all the mailboxes in the exchange servers and searched for the specific text in the users mailbox messages. I have two threads for two exchange servers and they run sequentially(one after another). for each thread mapi intialize is called in the beginning and MAPIUninitialize() is called when it is exiting. but the application crashes during MAPIUninitialize() function in the second thread.

Also i have made sure that all the pointers are released, even called  _CrtDumpMemoryLeaks() function to check if any of the memory leaks happened but it says not memory leaks.

I have observed that in MFCMAPI also some times it crashes when the MAPIUninitialize() function is called. I was just trying the MFCMAPI and when i log off from the profile and call MAPIUninitialize() function and when i close MFCMAPI it crashes(sometimes). Why is this happening. Is this a bug ?

Can somebody help me with this?





Dec 4, 2009 at 12:14 PM

Which MAPI do you have installed on this machine? Outlook? Exchange? Both?

Dec 30, 2009 at 1:02 AM

Hi, sgriffin, I met the same problem, after upgrading the MAPI to 6.5.8147, the problem appeared. I downloaded MAPI from the link you gave. 

My program crashed when it called MAPIUnitinitialize.  Before upgrading MAPI, everything was fine. I added some logic to generate DUMP file, according to the dump file, the crash occurred in the MAPI internally.  I found MAPIUnitinitialize frees MAPI DLL, but in the situation, there were some jobs running in the MAPI dll at the same time. After freeing library, the memory referenced by the MAPI dll became invalid, so it crashed.  Fortunately, I found a work around for the problem. If sleeping several seconds before calling MAPIUnitinitialize, it worked.


<font size="3">





Dec 30, 2009 at 6:53 AM

I've not seen this and cannot reproduce it here. Typically, crashes when calling MAPIUninitialize indicate that objects have been leaked, but without access to a crash dump to analyze there's little I can do to figure out the cause. It would help if someone who could reproduce this crash opened a case so we could gather crash dumps from them.

Dec 30, 2009 at 7:13 AM

I have five exchange servers, the problem occurred on two machines, not on the others. Both the two Exchange Servers are all in one.

My environment information:

OS: windows 2008 Sp2 Enterprise

ExchangeServer: Exchange Server 2010 RTM+ RU1, all in one.

MAPI version:  6.5.8147

And I found not only MAPIUninitialize could cause crash, so do LogOff and DeleteExchangeProfile fucntions.

sgriffin, I can reproduce the issue, but how could I give you the dump file? Need I open a issue for Microsoft?




Dec 30, 2009 at 1:32 PM

Opening a case is the best way to handle it. Before you do, I have to ask again - are you positive Outlook isn't installed on these machines? Having both Outlook and Exchange's MAPI on a machine is a certain way to cause this sort of crash, as the two similar but different implementations can get loaded in the same process and stomp all over each other's memory structures.

Dec 31, 2009 at 4:49 AM

yes, I know that problem, there is no outlook, I never installed it on these machines. And if I uninstall the latest MAPI, and user the old MAPI package, my program can work.