You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Chunrong Lai (JIRA)" <ji...@apache.org> on 2007/10/18 05:56:50 UTC

[jira] Created: (HARMONY-4963) [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden

[classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden
------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-4963
                 URL: https://issues.apache.org/jira/browse/HARMONY-4963
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
         Environment: Win32
            Reporter: Chunrong Lai



 In debugging of a hangup of some application I see below functions in Harmony:
 modules\awt\src\main\java\windows\org\apache\harmony\awt\wtk\windows:

    public void activate() {
        WinEventQueue.Task task = new WinEventQueue.Task() {
            @Override
            public void perform() {
                final long hwnd = win32.GetFocus();
                if (hwnd == 0l) return;
                long curIMC = win32.ImmGetContext(hwnd);
                if ((curIMC != 0) && isActiveClient()) {
                    win32.ImmSetOpenStatus(curIMC, 0);
                }
                if (curIMC != hIMC) {                    
                    long res = win32.ImmAssociateContext(hwnd, hIMC);
                    ......
                } else {
                    ......
                }
                win32.ImmReleaseContext(hwnd, curIMC);
            }
        };
        wwf.eventQueue.performTask(task);
        .....
    }    

    private static boolean isActiveClient() {
        InputMethodContext imc = IMManager.getLastActiveIMC();
        if ((imc == null) || (imc.getClient() == null)) {
            return false;
        }
        return (imc.getClient().getInputMethodRequests() != null);
    }

 In my understanding the imc.getClient().getInputMethodRequests(), executed in final WinEventQueue eventQueue, is thread unsafe if the getInputMethodRequests() is overridden by sub-components.

 The fix can be in several shapes:
  (1) Dispatch the task thread-safely, for example, make it in AWTEventDispatchThread.
  (2) Give a rule to getInputMethodRequests() to avoid free overriding. For example, if getInputMethodRequests() only return something or initialize something. We can force getClient().getInputMethodRequests() in InputMethod.activateIM() and InputMethod.switchIM() (to finish the initialization) so it will be thread-safe in winIM.activate(). 



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4963) [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden

Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539432 ] 

Chunrong Lai commented on HARMONY-4963:
---------------------------------------


  The patch may be not final but it fixes some hang up. 
  According to the original code segment in Harmony, IMManager.getLastActiveIMC().getClient().getInputMethodRequests() can be called from different places. Since the getInputMethodRequests() can be overridden to create/modify components, it is just very difficult for a programmer to write the thread-safe program.
  My patch assumes a simpler getInputMethodRequests() which has thread safety if it has been initialized even when it is overriden. 
  Anyway I welcome the discussion and feedback on this issue.

> [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4963
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4963
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Win32
>            Reporter: Chunrong Lai
>            Assignee: Alexei Zakharov
>         Attachments: H4963.1.patch
>
>
>  In debugging of a hangup of some application I see below functions in Harmony:
>  modules\awt\src\main\java\windows\org\apache\harmony\awt\wtk\windows:
>     public void activate() {
>         WinEventQueue.Task task = new WinEventQueue.Task() {
>             @Override
>             public void perform() {
>                 final long hwnd = win32.GetFocus();
>                 if (hwnd == 0l) return;
>                 long curIMC = win32.ImmGetContext(hwnd);
>                 if ((curIMC != 0) && isActiveClient()) {
>                     win32.ImmSetOpenStatus(curIMC, 0);
>                 }
>                 if (curIMC != hIMC) {                    
>                     long res = win32.ImmAssociateContext(hwnd, hIMC);
>                     ......
>                 } else {
>                     ......
>                 }
>                 win32.ImmReleaseContext(hwnd, curIMC);
>             }
>         };
>         wwf.eventQueue.performTask(task);
>         .....
>     }    
>     private static boolean isActiveClient() {
>         InputMethodContext imc = IMManager.getLastActiveIMC();
>         if ((imc == null) || (imc.getClient() == null)) {
>             return false;
>         }
>         return (imc.getClient().getInputMethodRequests() != null);
>     }
>  In my understanding the imc.getClient().getInputMethodRequests(), executed in final WinEventQueue eventQueue, is thread unsafe if the getInputMethodRequests() is overridden by sub-components.
>  The fix can be in several shapes:
>   (1) Dispatch the task thread-safely, for example, make it in AWTEventDispatchThread.
>   (2) Give a rule to getInputMethodRequests() to avoid free overriding. For example, if getInputMethodRequests() only return something or initialize something. We can force getClient().getInputMethodRequests() in InputMethod.activateIM() and InputMethod.switchIM() (to finish the initialization) so it will be thread-safe in winIM.activate(). 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-4963) [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12539380 ] 

Alexei Zakharov commented on HARMONY-4963:
------------------------------------------

Chunrong, I've applied your patch at the revision 591027. However, is this patch final? I still can't get how thread safety issues can be solved by adding an extra initialization. Could you please explain?

> [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4963
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4963
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Win32
>            Reporter: Chunrong Lai
>            Assignee: Alexei Zakharov
>         Attachments: H4963.1.patch
>
>
>  In debugging of a hangup of some application I see below functions in Harmony:
>  modules\awt\src\main\java\windows\org\apache\harmony\awt\wtk\windows:
>     public void activate() {
>         WinEventQueue.Task task = new WinEventQueue.Task() {
>             @Override
>             public void perform() {
>                 final long hwnd = win32.GetFocus();
>                 if (hwnd == 0l) return;
>                 long curIMC = win32.ImmGetContext(hwnd);
>                 if ((curIMC != 0) && isActiveClient()) {
>                     win32.ImmSetOpenStatus(curIMC, 0);
>                 }
>                 if (curIMC != hIMC) {                    
>                     long res = win32.ImmAssociateContext(hwnd, hIMC);
>                     ......
>                 } else {
>                     ......
>                 }
>                 win32.ImmReleaseContext(hwnd, curIMC);
>             }
>         };
>         wwf.eventQueue.performTask(task);
>         .....
>     }    
>     private static boolean isActiveClient() {
>         InputMethodContext imc = IMManager.getLastActiveIMC();
>         if ((imc == null) || (imc.getClient() == null)) {
>             return false;
>         }
>         return (imc.getClient().getInputMethodRequests() != null);
>     }
>  In my understanding the imc.getClient().getInputMethodRequests(), executed in final WinEventQueue eventQueue, is thread unsafe if the getInputMethodRequests() is overridden by sub-components.
>  The fix can be in several shapes:
>   (1) Dispatch the task thread-safely, for example, make it in AWTEventDispatchThread.
>   (2) Give a rule to getInputMethodRequests() to avoid free overriding. For example, if getInputMethodRequests() only return something or initialize something. We can force getClient().getInputMethodRequests() in InputMethod.activateIM() and InputMethod.switchIM() (to finish the initialization) so it will be thread-safe in winIM.activate(). 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-4963) [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden

Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chunrong Lai updated HARMONY-4963:
----------------------------------

    Attachment: H4963.1.patch


 Here is the patch.

> [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4963
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4963
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Win32
>            Reporter: Chunrong Lai
>         Attachments: H4963.1.patch
>
>
>  In debugging of a hangup of some application I see below functions in Harmony:
>  modules\awt\src\main\java\windows\org\apache\harmony\awt\wtk\windows:
>     public void activate() {
>         WinEventQueue.Task task = new WinEventQueue.Task() {
>             @Override
>             public void perform() {
>                 final long hwnd = win32.GetFocus();
>                 if (hwnd == 0l) return;
>                 long curIMC = win32.ImmGetContext(hwnd);
>                 if ((curIMC != 0) && isActiveClient()) {
>                     win32.ImmSetOpenStatus(curIMC, 0);
>                 }
>                 if (curIMC != hIMC) {                    
>                     long res = win32.ImmAssociateContext(hwnd, hIMC);
>                     ......
>                 } else {
>                     ......
>                 }
>                 win32.ImmReleaseContext(hwnd, curIMC);
>             }
>         };
>         wwf.eventQueue.performTask(task);
>         .....
>     }    
>     private static boolean isActiveClient() {
>         InputMethodContext imc = IMManager.getLastActiveIMC();
>         if ((imc == null) || (imc.getClient() == null)) {
>             return false;
>         }
>         return (imc.getClient().getInputMethodRequests() != null);
>     }
>  In my understanding the imc.getClient().getInputMethodRequests(), executed in final WinEventQueue eventQueue, is thread unsafe if the getInputMethodRequests() is overridden by sub-components.
>  The fix can be in several shapes:
>   (1) Dispatch the task thread-safely, for example, make it in AWTEventDispatchThread.
>   (2) Give a rule to getInputMethodRequests() to avoid free overriding. For example, if getInputMethodRequests() only return something or initialize something. We can force getClient().getInputMethodRequests() in InputMethod.activateIM() and InputMethod.switchIM() (to finish the initialization) so it will be thread-safe in winIM.activate(). 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-4963) [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-4963.
--------------------------------------

    Resolution: Fixed

Thanks for explanation, Chunrong. Do you expect more activity about this issue or we can close it?

> [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4963
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4963
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Win32
>            Reporter: Chunrong Lai
>            Assignee: Alexei Zakharov
>         Attachments: H4963.1.patch
>
>
>  In debugging of a hangup of some application I see below functions in Harmony:
>  modules\awt\src\main\java\windows\org\apache\harmony\awt\wtk\windows:
>     public void activate() {
>         WinEventQueue.Task task = new WinEventQueue.Task() {
>             @Override
>             public void perform() {
>                 final long hwnd = win32.GetFocus();
>                 if (hwnd == 0l) return;
>                 long curIMC = win32.ImmGetContext(hwnd);
>                 if ((curIMC != 0) && isActiveClient()) {
>                     win32.ImmSetOpenStatus(curIMC, 0);
>                 }
>                 if (curIMC != hIMC) {                    
>                     long res = win32.ImmAssociateContext(hwnd, hIMC);
>                     ......
>                 } else {
>                     ......
>                 }
>                 win32.ImmReleaseContext(hwnd, curIMC);
>             }
>         };
>         wwf.eventQueue.performTask(task);
>         .....
>     }    
>     private static boolean isActiveClient() {
>         InputMethodContext imc = IMManager.getLastActiveIMC();
>         if ((imc == null) || (imc.getClient() == null)) {
>             return false;
>         }
>         return (imc.getClient().getInputMethodRequests() != null);
>     }
>  In my understanding the imc.getClient().getInputMethodRequests(), executed in final WinEventQueue eventQueue, is thread unsafe if the getInputMethodRequests() is overridden by sub-components.
>  The fix can be in several shapes:
>   (1) Dispatch the task thread-safely, for example, make it in AWTEventDispatchThread.
>   (2) Give a rule to getInputMethodRequests() to avoid free overriding. For example, if getInputMethodRequests() only return something or initialize something. We can force getClient().getInputMethodRequests() in InputMethod.activateIM() and InputMethod.switchIM() (to finish the initialization) so it will be thread-safe in winIM.activate(). 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-4963) [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-4963:
----------------------------------------

    Assignee: Alexei Zakharov

> [classlib][awt] possible hang up when activate windows-InputMethod if getInputMethodRequests() is overridden
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4963
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4963
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Win32
>            Reporter: Chunrong Lai
>            Assignee: Alexei Zakharov
>         Attachments: H4963.1.patch
>
>
>  In debugging of a hangup of some application I see below functions in Harmony:
>  modules\awt\src\main\java\windows\org\apache\harmony\awt\wtk\windows:
>     public void activate() {
>         WinEventQueue.Task task = new WinEventQueue.Task() {
>             @Override
>             public void perform() {
>                 final long hwnd = win32.GetFocus();
>                 if (hwnd == 0l) return;
>                 long curIMC = win32.ImmGetContext(hwnd);
>                 if ((curIMC != 0) && isActiveClient()) {
>                     win32.ImmSetOpenStatus(curIMC, 0);
>                 }
>                 if (curIMC != hIMC) {                    
>                     long res = win32.ImmAssociateContext(hwnd, hIMC);
>                     ......
>                 } else {
>                     ......
>                 }
>                 win32.ImmReleaseContext(hwnd, curIMC);
>             }
>         };
>         wwf.eventQueue.performTask(task);
>         .....
>     }    
>     private static boolean isActiveClient() {
>         InputMethodContext imc = IMManager.getLastActiveIMC();
>         if ((imc == null) || (imc.getClient() == null)) {
>             return false;
>         }
>         return (imc.getClient().getInputMethodRequests() != null);
>     }
>  In my understanding the imc.getClient().getInputMethodRequests(), executed in final WinEventQueue eventQueue, is thread unsafe if the getInputMethodRequests() is overridden by sub-components.
>  The fix can be in several shapes:
>   (1) Dispatch the task thread-safely, for example, make it in AWTEventDispatchThread.
>   (2) Give a rule to getInputMethodRequests() to avoid free overriding. For example, if getInputMethodRequests() only return something or initialize something. We can force getClient().getInputMethodRequests() in InputMethod.activateIM() and InputMethod.switchIM() (to finish the initialization) so it will be thread-safe in winIM.activate(). 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.