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

620661: RACE CONDITION IN AWT_DIALOG SHOWMODAL()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.1.7
    • 1.1, 1.1.3, 1.1.4, 1.1.5, 1.2.0
    • client-libs
    • b01
    • generic, x86
    • generic, windows_95, windows_nt
    • Not verified



        Name: ccC48265 Date: 02/06/98


        When a Dialog is closed, the c++ object associated with the Dialog may be freed
        and reallocated before the thread that calls ShowModal() is activated.
        ShowModal() assumes that the object is still usable and calls SetStyle().
        To prevent this race condition, the HWND should be stored in a local variable,
        before the thread is suspended, so that the c++ object is not required.

        The HWND may be invalid by the time it is used but Windows deals with this
        safely.
        New code in awt_Dialog
        void AwtDialog::ShowModal()
        {
            /* Save the hwnd on the stack, so that if the c++ object is deleted
            ** before this thread is woken up, we don't try to get the hwnd from freed
            ** up memory
            */
            HWND hwnd = GetHWnd();
        :
        :
            // Remove modal styles set before show, incase next show is non-modal
            ::SetWindowLong(hwnd, GWL_STYLE,
                                  ::GetWindowLong(hwnd, GWL_STYLE) & ~DS_MODALFRAME);
            if (IS_WIN4X) {
        DWORD exStyle = ::GetWindowLong(hwnd, GWL_EXSTYLE) & ~WS_EX_DLGMODALFRAME;
        ::SetWindowLong(hwnd, GWL_EXSTYLE, exStyle);
            }
        }
        The SetWindowLong(hwnd, GWL_STYLE replaces the SetStyle/GetStyle() code. Note
        that GetHWnd() has been replaced by hwnd.
        (Review ID: 24580)
        ======================================================================

              rkhansunw Robi Khan (Inactive)
              ccresswesunw Claudette Cresswell (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: