none
Outlook 2016 mapi.MAPIUninitialize() crashes RRS feed

  • Question

  • Hi,

    In my multi threaded application where multiple threads do mapi initialize by
    mapi.MAPIInitialize((0, mapi.MAPI_MULTITHREAD_NOTIFICATIONS))

    mapi.MAPIUninitialize() crashes. I got the following call stack from windbg.

    mso30win32client!Ordinal250+0x32423
    mso30win32client!Ordinal126+0x5b
    mso30win32client!Ordinal1337+0x39d
    mso30win32client!Ordinal1470+0x17e
    mso30win32client!Ordinal1470+0xe
    mso40uiwin32client!Ordinal2408+0x19
    olmapi32!LINKEDLIST_RemoveKey+0x4e6
    olmapi32!HrUninitMso+0x36
    olmapi32!MAPIUninitialize+0x9
    MSMAPI32!MAPIUninitialize+0x42
    MAPI32!MAPIUninitialize+0x5b
    mapi+0x11d9 

    Each thread does only following mapi calls in sequence :
    1 MAPIInitialize -> mapi.MAPIInitialize((0, mapi.MAPI_MULTITHREAD_NOTIFICATIONS))
    2 MAPIAdminProfiles -> adminprof = mapi.MAPIAdminProfiles(0)
    3 HrQueryAllRows ->tab = self.adminprof.GetProfileTable(0)
    rows = mapi.HrQueryAllRows(tab, (PR_DEFAULT_PROFILE,PR_DISPLAY_NAME_A), None, None, 0)

    4 MAPILogonEx -> session = mapi.MAPILogonEx(0, profile, None, logonFlags)
    where logonFlgs = mapi.MAPI_NO_MAIL|mapi.MAPI_EXTENDED|mapi.MAPI_NEW_SESSION

    5 session.Logoff(0,0,0)
    6 mapi.MAPIUninitialize()

    Observation:
    If there are two threads T1 and T2 .
    T1 logs in to session prior to T2 and T1 does MAPIUninitialize after T2 it dont lead to crash, 
    But if T1 logs in to session prior to T2 and T1 does MAPIUninitialize before T2 then call to MAPIUninitialize leads to crash with above stack.

    PS : Crash occurs with Outlook 2016 and works fine with Outlook 2013 and prior.




    • Edited by cmits2016 Tuesday, December 1, 2015 6:40 AM
    Tuesday, December 1, 2015 6:10 AM

Answers

All replies

  • Is T1 used on the main thread and T2 on a secondary?

    Take a look at the MAPI Multithreading Rules page which states the following:

    If MAPI_MULTITHREAD_NOTIFICATIONS is not used, the first thread to call MAPIInitialize should live longer than all other MAPI threads and should be the last to call MAPIUninitialize.

    Looks like the mentioned flag doesn't play any role now and you should preserve the sequence of calls, i.e. use LIFO (last in, first out).

    Tuesday, December 1, 2015 9:47 AM
  • Thanks Eugene for the response.

    Here T1 and T2 are threads at Sibling level,created by a thread say M.

    Thread M do not do any mapi calls Hence I am not doing  mapi.MAPIInitialize  and mapi.MAPIUninitialize for thread M.

    Is this could be the issue ?

      


    • Edited by cmits2016 Tuesday, December 1, 2015 10:27 AM
    Tuesday, December 1, 2015 10:26 AM
  • I don't think so. Looks like the sequence plays more vital role now in Outlook 2016.
    Tuesday, December 1, 2015 10:35 AM
  • There are some more observations I would like to add

    If T1 and T2 dont do MAPILogonEx call then  mapi.MAPIUninitialize() succeeds in any sequence.

    If either of T1 or T2 do MAPILogonEx  call then the thread that had call MAPILogonEx  must do last mapi.MAPIUninitialize() of two.

    Is it the sequence of of  MAPIInitialize or MAPILogonEx call ?

    By the way Can you explain what above windbg call stack indicates.

    Tuesday, December 1, 2015 10:52 AM
    • Edited by RLWA32 Tuesday, December 1, 2015 11:44 AM
    • Marked as answer by David_JunFeng Tuesday, December 15, 2015 1:35 AM
    Tuesday, December 1, 2015 11:43 AM