CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 33
  1. #1
    Join Date
    Aug 2011
    Posts
    38

    VS2010&OLE32.dll access violation problem with COM

    My program using COM and some DLLs and this program invokes access violation exception when I close the application. I've grabbing information below


    - dli {cb=36 pidd=0x5caf5a1c ppfn=0x5cb175e4 ...} DelayLoadInfo
    cb 36 unsigned long
    + pidd 0x5caf5a1c __DELAY_IMPORT_DESCRIPTOR_ole32_dll {grAttrs=1 rvaDLLName=429088 rvaHmod=5561600 ...} const ImgDelayDescr *
    + ppfn 0x5cb175e4 __imp__CoUninitialize@0 int (void)* *
    + szDll 0x5c638c20 "ole32.dll" const char *
    + dlp {fImportByName=1 szProcName=0x5caf627a "CoUninitialize" dwOrdinal=1554997882 } DelayLoadProc
    + hmodCur 0x74df0000 {unused=9460301 } HINSTANCE__ *
    pfnCur 0x00000000 int (void)*
    dwLastError 0 unsigned long
    - dli.dlp {fImportByName=1 szProcName=0x5caf627a "CoUninitialize" dwOrdinal=1554997882 } DelayLoadProc
    fImportByName 1 int
    - szProcName 0x5caf627a "CoUninitialize" const char *
    67 'C' const char
    dwOrdinal 1554997882 unsigned long
    - dli.dlp.szProcName 0x5caf627a "CoUninitialize" const char *
    67 'C' const char

    it seems CoUninitialize method involves some bad memory manipulations.
    This problem does not occurs on the VS2008.
    Why does this occurs ?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: VS2010&OLE32.dll access violation problem with COM

    If you are using COM smart pointers and calling CoUninitialize before the smart pointer goes out of scope, you can see a similar issue.

  3. #3
    Join Date
    Aug 2011
    Posts
    38

    Re: VS2010&OLE32.dll access violation problem with COM

    But, I hadn't saw this problem on VS2008.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: VS2010&OLE32.dll access violation problem with COM

    Well, it doesn't matter, had you or had not. What matters is to call CoUnintialize only after all smartpointers left their scopes, or were nullified to the moment otherwise. You make sure this is done and see if the problem has gone.
    Best regards,
    Igor

  5. #5
    Join Date
    Aug 2011
    Posts
    38

    Re: VS2010&OLE32.dll access violation problem with COM

    Do you mean the 'smart pointer' as COM's smart pointers ?
    How is the boost::shared_ptr ?

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: VS2010&OLE32.dll access violation problem with COM

    Okay. The problem mentioned by Arjay relates to having non released COM interfaces while CoInitialize gets called. Now it's up to you to get what kind of smart pointers it's about.
    Best regards,
    Igor

  7. #7
    Join Date
    Aug 2011
    Posts
    38

    Re: VS2010&OLE32.dll access violation problem with COM

    Thanks.
    I'm using many CComQIPtr(s) and released all of them before CoUninitialize and checked timing of release, therefor I couldn't resolve this issue. Why?

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: VS2010&OLE32.dll access violation problem with COM

    So you are sure about interfaces being timely released. Then another suspect (pretty obvious, I'd say) is delayed load. Did you try to remove it?
    Best regards,
    Igor

  9. #9
    Join Date
    Aug 2011
    Posts
    38

    Re: VS2010&OLE32.dll access violation problem with COM

    I've known the delay load of DLL but have not known the delay load around COM and CComPtr(or CComQIPtr). What is that ?
    I haven't using delay loaded DLL(s).

    Additionally, I've using Skype4COM.dll by '#import' pragma to communicate with the SkypeAPI and running the initialization process like below on the beginning of a worker thread

    CoInitialize(NULL);
    // Create object
    ISkypePtr pSkype(__uuidof(Skype));
    // Create sink
    scoped_ptr<CSkypeEvents> pSink( new CSkypeEvents(man) );
    HRESULT hr(S_OK);
    // Connect events
    hr = pSink->DispEventAdvise(pSkype);
    if( NULL == pSkype ){
    }
    // Attach to API
    hr = pSkype->Attach(5, VARIANT_TRUE);
    if( FAILED(hr) ){
    }

    But, ntdll.dll issue will occurs if I will not run this procedure.
    Last edited by lightshield; August 20th, 2011 at 10:43 AM.

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: VS2010&OLE32.dll access violation problem with COM

    Quote Originally Posted by lightshield View Post
    I've known the delay load of DLL but have not known the delay load around COM and CComPtr(or CComQIPtr). What is that ?
    I haven't using delay loaded DLL(s).

    Additionally, I've using Skype4COM.dll by '#import' pragma to communicate with the SkypeAPI and running the initialization process like below on the beginning of a worker thread

    CoInitialize(NULL);
    // Create object
    ISkypePtr pSkype(__uuidof(Skype));
    // Create sink
    scoped_ptr<CSkypeEvents> pSink( new CSkypeEvents(man) );
    HRESULT hr(S_OK);
    // Connect events
    hr = pSink->DispEventAdvise(pSkype);
    if( NULL == pSkype ){
    }
    // Attach to API
    hr = pSkype->Attach(5, VARIANT_TRUE);
    if( FAILED(hr) ){
    }

    But, ntdll.dll issue will occurs if I will not run this procedure.
    In the code above, where does CoUninitialize get called?

  11. #11
    Join Date
    Aug 2011
    Posts
    38

    Re: VS2010&OLE32.dll access violation problem with COM

    The above code is just the initializing part. CoUninitialize is used in my program.

  12. #12
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: VS2010&OLE32.dll access violation problem with COM

    Quote Originally Posted by lightshield View Post
    The above code is just the initializing part. CoUninitialize is used in my program.
    Look, you've got a problem that we suspect is due to the scoping of the COM smart pointers getting released after your call to CoUninitialize. Of course, we don't know for sure until we see your code.

    So can we just save time here and have you post the complete code from CoInitialize to CoUninitialize?

  13. #13
    Join Date
    Aug 2011
    Posts
    38

    Re: VS2010&OLE32.dll access violation problem with COM

    My worker thread routine is as below.

    Code:
    class Worker{
      Worker(){}
      void operator()(void)
      {
         CoInitialize(NULL);
    
         // init skype api dll
         
         while(true){
              // skype api procedures using Skype4COM.dll
         }
    
         CoUninitialize();
      }
    };
    This is a worker thread and this thread will only uses skype-api's produced by Skype's DLL.
    BUT I've unloading Skype-DLL on the main thread. This procedure maybe the cause of this problem. I'll try to remove this procedure to detect an affected part of my sources.

    Sorry Igor, I might have using delayed load.
    Last edited by lightshield; August 20th, 2011 at 03:59 PM.

  14. #14
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: VS2010&OLE32.dll access violation problem with COM

    Please use [Code][/Code] tags.

    What does the following mean?
    Code:
              // skype api procedures using Skype4COM.dll
    Are using COM to access this dll? Or do you call LoadLibrary?

    If Skype4Com.dll is a COM dll, then you don't need to call LoadLibrary ANYWHERE (because the COM subsystem handles that for you).

  15. #15
    Join Date
    Aug 2011
    Posts
    38

    Re: VS2010&OLE32.dll access violation problem with COM

    skype4COM is a COM library.
    I didn't use LoadLibrary so I didn't use delayed load.

    I've using '#import' pragma to import Skype's class information like below in the cpp file that implementing Skype client functionalities.

    Code:
    #import ".\\Skype4COM.dll" named_guids

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured