<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thank you, Anton!<div class=""><br class=""></div><div class="">Sergey,</div><div class="">Any remarks regarding the updated fix?</div><div class=""><a href="http://cr.openjdk.java.net/~dmarkov/8232114/webrev.02/" class="">http://cr.openjdk.java.net/~dmarkov/8232114/webrev.02/</a></div><div class=""><br class=""></div><div class="">Thanks in advance,</div><div class="">Dmitry<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 25 Aug 2020, at 00:35, Anton Litvinov <<a href="mailto:anton.litvinov@oracle.com" class="">anton.litvinov@oracle.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
  
  <div class="">
    Hi Dmitry,<br class="">
    <br class="">
    The fix looks good. Thank you for taking into account my
    suggestions.<br class="">
    <br class="">
    Thank you,<br class="">
    Anton<br class="">
    <br class="">
    <div class="moz-cite-prefix">On 24/08/2020 10:10, Dmitry Markov
      wrote:<br class="">
    </div>
    <blockquote type="cite" cite="mid:889CC26F-E996-42AA-8893-6BA3A685AC70@oracle.com" class="">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
      Hi Anton,
      <div class=""><br class="">
      </div>
      <div class="">Thank you for review. I have updated the fix based
        on your suggestions: </div>
      <div class=""> - Modified the function InvokeInputMethodFunction()
        to take into account the result of PostMessage() call</div>
      <div class=""> - Replaced InvokeInputMethodFunction() with
        SendMessage() for WM_AWT_HANDLE_NATIVE_IME_EVENT and
        WM_AWT_ACTIVATEKEYBOARDLAYOUT. I didn’t update the code related
        to WM_AWT_OPENCANDIDATEWINDOW message because we can call IME
        API during its processing, (e.g. AwtToolkit::WndProc() ->
        AwtComponent::OpenCandidateWindow() ->
        AwtComponent::SetCandidateWindow() -> Imm*).</div>
      <div class=""><br class="">
      </div>
      <div class="">The new web rev is located at <a href="http://cr.openjdk.java.net/~dmarkov/8232114/webrev.02/" class="" moz-do-not-send="true">http://cr.openjdk.java.net/~dmarkov/8232114/webrev.02/</a></div>
      <div class=""><br class="">
      </div>
      <div class="">Regards,</div>
      <div class="">Dmitry<br class="">
        <div class=""><br class="">
          <blockquote type="cite" class="">
            <div class="">On 20 Aug 2020, at 15:14, Anton Litvinov <<a href="mailto:ANTON.LITVINOV@ORACLE.COM" class="" moz-do-not-send="true">ANTON.LITVINOV@ORACLE.COM</a>>
              wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <meta http-equiv="Content-Type" content="text/html;
                charset=UTF-8" class="">
              <div class=""> Hi Dmitry,<br class="">
                <br class="">
                The fix looks well, but I have next a few comments
                relatively to it:<br class="">
                <br class="">
                1) In the new function
                "AwtToolkit::InvokeInputMethodFunction(UINT, WPARAM,
                LPARAM)", which you created, the call "PostMessage(msg,
                wParam, lParam);" may fail and return "0", so in that
                case the next call
                "::WaitForSingleObject(m_inputMethodWaitEvent,
                INFINITE);" may become blocked forever. I suggest to
                handle this possible failure, for example in the next
                way:<br class="">
                <br class="">
                if (PostMessage(msg, wParam, lParam)) {<br class="">
                    ::WaitForSingleObject(m_inputMethodWaitEvent,
                INFINITE);<br class="">
                    return m_inputMethodData;<br class="">
                }<br class="">
                return 0;<br class="">
                <br class="">
                2) In "AwtToolkit::WndProc" function in the code
                handling the messages: "WM_AWT_HANDLE_NATIVE_IME_EVENT",
                "WM_AWT_ACTIVATEKEYBOARDLAYOUT",
                "WM_AWT_OPENCANDIDATEWINDOW" I do not find calls to
                "Imm*" system functions. Therefore maybe there is no
                need to send these messages through "PostMessage"?<br class="">
                <br class="">
                Thank you,<br class="">
                Anton<br class="">
                <br class="">
                <div class="moz-cite-prefix">On 18/08/2020 06:46, Dmitry
                  Markov wrote:<br class="">
                </div>
                <blockquote type="cite" cite="mid:0C09A39C-E0BA-4C88-B2BD-7549CA7A3F50@oracle.com" class="">
                  <meta http-equiv="Content-Type" content="text/html;
                    charset=UTF-8" class="">
                  Thank you, Sergey!
                  <div class=""><br class="">
                  </div>
                  <div class="">Looking for one more "+1”. Any
                    volunteers?<br class="">
                    <div class=""><br class="">
                    </div>
                    <div class="">Regards,</div>
                    <div class="">Dmitry<br class="">
                      <blockquote type="cite" class="">
                        <div class="">On 17 Aug 2020, at 21:06, Sergey
                          Bylokhov <<a href="mailto:sergey.bylokhov@oracle.com" class="" moz-do-not-send="true">sergey.bylokhov@oracle.com</a>>
                          wrote:</div>
                        <br class="Apple-interchange-newline">
                        <div class=""><span style="caret-color: rgb(0,
                            0, 0); font-family: Helvetica; font-size:
                            12px; font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none; float: none; display:
                            inline !important;" class="">Looks fine.</span><br style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none;" class="">
                          <br style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none;" class="">
                          <span style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none; float: none; display:
                            inline !important;" class="">On 17.08.2020
                            02:32, Dmitry Markov wrote:</span><br style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none;" class="">
                          <blockquote type="cite" style="font-family:
                            Helvetica; font-size: 12px; font-style:
                            normal; font-variant-caps: normal;
                            font-weight: normal; letter-spacing: normal;
                            orphans: auto; text-align: start;
                            text-indent: 0px; text-transform: none;
                            white-space: normal; widows: auto;
                            word-spacing: 0px; -webkit-text-size-adjust:
                            auto; -webkit-text-stroke-width: 0px;
                            text-decoration: none;" class="">Hi Sergey,<br class="">
                            I have added that information to
                            InvokeInputMethodFunction(). Please find the
                            new webrev here:<span class="Apple-converted-space"> </span><a href="http://cr.openjdk.java.net/~dmarkov/8232114/webrev.01/" class="" moz-do-not-send="true">http://cr.openjdk.java.net/~dmarkov/8232114/webrev.01/</a><br class="">
                            Regards,<br class="">
                            Dmitry<br class="">
                            <blockquote type="cite" class="">On 15 Aug
                              2020, at 03:05, Sergey Bylokhov <<a href="mailto:sergey.bylokhov@oracle.com" class="" moz-do-not-send="true">sergey.bylokhov@oracle.com</a><span class="Apple-converted-space"> </span><<a href="mailto:sergey.bylokhov@oracle.com" class="" moz-do-not-send="true">mailto:sergey.bylokhov@oracle.com</a>>>
                              wrote:<br class="">
                              <br class="">
                              On 12.08.2020 05:09, Dmitry Markov wrote:<br class="">
                              <blockquote type="cite" class="">TranslateMessage()
                                does not invoke PeekMessage(). In our
                                case TranslateMessage() is called by
                                AWT. IME functionality may call
                                PeekMessage() during TranslateMessage()
                                execution. However that PeekMessage()
                                call is intended for processing
                                non-queued  messages, (i.e. the messages
                                send via SendMessage() call).<br class="">
                                I contacted Microsoft regarding this
                                problem and one of their suggestions was
                                to use PostMessage() instead of
                                SendMessage() for IME messages to avoid
                                IME internal data corruption and the
                                crash.<br class="">
                                The proposed fix was tested by the
                                stress test for several weeks and no
                                issues were observed. So I feel quite
                                confident that it eliminates the issue.<br class="">
                                There is no exact message which triggers
                                the crash. Usually the crash is caused
                                by one of the following messages:
                                WM_AWT_ASSOCIATECONTEXT or
                                WM_AWT_SETOPENSTATUS but several times I
                                observed that it was triggered by
                                WM_AWT_DESTROYCONTEXT or
                                WM_AWT_CREATECONTEXT. It looks like
                                almost every IME-related message may
                                cause the crash.  I think SendMessage()
                                call should be substituted by
                                PostMessage() for all IME messages.<br class="">
                              </blockquote>
                              <br class="">
                              Ok, then please add this(or similar)
                              information to the new method
                              "InvokeInputMethodFunction",<br class="">
                              otherwise it could be removed in the
                              future/replaced back to the sendMessage.<br class="">
                              <br class="">
                              <blockquote type="cite" class="">Regards,<br class="">
                                Dmitry<br class="">
                                <blockquote type="cite" class="">On 12
                                  Aug 2020, at 06:16, Sergey Bylokhov
                                  <<a href="mailto:Sergey.Bylokhov@oracle.com" class="" moz-do-not-send="true">Sergey.Bylokhov@oracle.com</a><span class="Apple-converted-space"> </span><<a href="mailto:Sergey.Bylokhov@oracle.com" class="" moz-do-not-send="true">mailto:Sergey.Bylokhov@oracle.com</a>>>
                                  wrote:<br class="">
                                  <br class="">
                                  Hi, Dmitry.<br class="">
                                  <br class="">
                                  On 11.08.2020 01:07, Dmitry Markov
                                  wrote:<br class="">
                                  <blockquote type="cite" class="">Problem
                                    description:<br class="">
                                    The root cause of the crash is the
                                    lack of synchronisation in
                                    imjpapi.dll. In particular when IME
                                    messages are processed in the
                                    message loop and another message
                                    triggered through a SendMessage()
                                    call, this clears the buffer context
                                    so on further processing the message
                                    loop in IME context will point to
                                    invalid memory buffer. Microsoft
                                    article devoted to this issue: <a href="https://docs.microsoft.com/en-us/troubleshoot/windows/win32/ime-crash-processing-cross-thread-sent-message" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/troubleshoot/windows/win32/ime-crash-processing-cross-thread-sent-message</a><br class="">
                                  </blockquote>
                                  <br class="">
                                  The documentation above also states
                                  that PeekMessage, called by the
                                  TranslateMessage when the IME is ON,
                                  can proceed the posted messages as
                                  well if that true then the current fix
                                  does not help.<br class="">
                                  <br class="">
                                  <blockquote type="cite" class="">Fix:<br class="">
                                    Replace SendMessage() with
                                    PostMessage() for IME messages and
                                    implement event based mechanism to
                                    notify the sender that the message
                                    processing is completed.<br class="">
                                  </blockquote>
                                  <br class="">
                                  What exact message broke the IME, the
                                  "WM_AWT_DESTROYCONTEXT"?<br class="">
                                  <br class="">
                                  <blockquote type="cite" class="">Testing:<br class="">
                                    mach5 client tests (jtreg headful,
                                    jck, etc.) are green.<br class="">
                                    Regards,<br class="">
                                    Dmitry<br class="">
                                  </blockquote>
                                  <br class="">
                                  <br class="">
                                  --<br class="">
                                  Best regards, Sergey.<br class="">
                                </blockquote>
                              </blockquote>
                              <br class="">
                              <br class="">
                              --<br class="">
                              Best regards, Sergey.<br class="">
                            </blockquote>
                          </blockquote>
                          <br style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none;" class="">
                          <br style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none;" class="">
                          <span style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none; float: none; display:
                            inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none;" class="">
                          <span style="caret-color: rgb(0, 0, 0);
                            font-family: Helvetica; font-size: 12px;
                            font-style: normal; font-variant-caps:
                            normal; font-weight: normal; letter-spacing:
                            normal; text-align: start; text-indent: 0px;
                            text-transform: none; white-space: normal;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;
                            text-decoration: none; float: none; display:
                            inline !important;" class="">Best regards,
                            Sergey.</span></div>
                      </blockquote>
                    </div>
                    <br class="">
                  </div>
                </blockquote>
                <br class="">
              </div>
            </div>
          </blockquote>
        </div>
        <br class="">
      </div>
    </blockquote>
    <br class="">
  </div>

</div></blockquote></div><br class=""></div></body></html>