Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7022842

Access violation in DnD : A thread which uses COM must call CoInitializeEx() or OleInitialize()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3
    • 5.0u22
    • 5.0u22
    • client-libs
    • x86
    • windows_xp

    Description

      A CU faces with process crash(access violation) during DnD operation.

      The access violation occurs at ole32.dll called from CoLockObjectExternal()
      in AwtComponent::DestroyDropTarget().

      There seems a bug in AWT source code in jdk5ux.

      INVESTIGATION:
      According to the MS docimentation, a thread which calls COM functions must call
      CoInitializeEx() or OleInitialize() in order to initialize COM before calling the COM functions.

      In jdk5u22, OleInitialize() is called in the following portion of source code.
      This is done in "AWT-Windows" thread.

      --- j2se/src/windows/native/sun/windows/awt_DnDDT.cpp (jdk5u22)----
      1208 void awt_dnd_initialize() {
      1209 ::OleInitialize((LPVOID)NULL);
      1210 }
      -------------------------------------------

      On the other hands, AwtComponent::DestroyDropTarget() and AwtComponent::CreateDropTarget()
      which actually call COM functions, are executed in "AWT-EventQueue-0" or user thread
      of java.awt.dnd.DropTarget.

      In other words, the thread which actually uses COM(calls COM functions) does not initialize COM,
      which is, does not call CoInitializeEx() or OleInitialize() .

      This seems to go against the following statement (guideline) in Remarks seciton of [3].
      "CoInitializeEx must be called at least once, and is usually called only once, for each thread that uses the COM library."

      NOTE:
      MS documentations

      [1] OleInitialize():
      http://msdn.microsoft.com/en-us/library/ms690134(v=vs.85).aspx
      [2] CoLockObjectExternal():
      http://msdn.microsoft.com/en-us/library/ms680592(v=vs.85).aspx
      [3] CoInitializeEx():
      http://msdn.microsoft.com/en-us/library/ms695279(v=vs.85).aspx

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tbaba Tadayuki Baba (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: