Bug 494586

Summary: Selecting the child of a menu can cause the application to crash
Product: [Mono] UI Automation Reporter: Brian Merrell <bgmerrell>
Component: Winforms - GeneralAssignee: Sanford Armstrong <saarmstrong>
Status: VERIFIED FIXED QA Contact: E-mail List <mono-a11y-qa>
Severity: Critical    
Priority: P2 - High    
Version: Release 1.0   
Target Milestone: Release 1.1   
Hardware: x86   
OS: Linux   
Whiteboard:
Found By: Integration Test Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Script referenced in REPRO steps

Description Brian Merrell 2009-04-14 06:58:54 UTC
PROBLEM STATEMENT

Selecting a menu child of a menu parent causes crash if the menu parent's menu bar parent (i.e., the menu child's grandparent) is not selected first.  To illustrate, consider the menustrip.py sample application:

The menustrip.py sample application has a menu bar (or MenuStrip) that has a 'File' menu.  The 'File' menu has several children, the first of which is another menu labeled 'New'.  The application will crash if the 'New' menu is selected by calling pyatspi's querySelection().selectChild(0) from the 'File' menu accessible, unless the querySelection().selectChild(0) was previous called from the menu bar accessible.

REPRO

1.  Run uia2atk/test/samples/menustrip.py
2.  Run the attached script, which does the following:
    a.  Finds the "File" menu accessible
    b.  Attempts to select it's 1st child, which is the "New" menu.

RESULTS

The application crashes, and prints the following trace:

Traceback (most recent call last):
  File UIAutomationWinforms, line unknown, in PerformClick
  File System.Windows.Forms, line unknown, in ShowDropDown
  File System.Windows.Forms, line unknown, in get_DropDownLocation
  File menustrip, line unknown, in Initialize
  File System.Windows.Forms, line unknown, in Run
  File System.Windows.Forms, line unknown, in Run
  File System.Windows.Forms, line unknown, in RunLoop
  File System.Windows.Forms, line unknown, in GetMessage
  File System.Windows.Forms, line unknown, in GetMessage
  File System.Windows.Forms, line unknown, in ExecuteClientMessage
  File mscorlib, line unknown, in Run
  File mscorlib, line unknown, in Run
  File System.Windows.Forms, line unknown, in ExecutionCallback
  File mscorlib, line unknown, in DynamicInvoke
  File mscorlib, line unknown, in DynamicInvokeImpl
  File mscorlib, line unknown, in DynamicInvokeImpl
StandardError: Exception has been thrown by the target of an invocation.
Segmentation fault

EXPECTED RESULTS

Application should not crash.  It looks like Gtk doesn't display anything when something similar is attempted there.  But it doesn't seem like querySelection().selectChild(n) works that well for Gtk's MenuBar either.  So I am not entirely sure what we should do here... but we definitely shouldn't crash :)

COMMENTS

You can uncomment lines 18-20 in the attached script and then run it to see that the application doesn't crash if the 'File' menu is selected before trying to select the 'File' menu's child.

Another thing that may be worth mentioning:  Pressing 'Escape' immediately after opening the 'File' menu dismisses the 'File' menu, but selecting the 'File' menu's child afterwards doesn't not crash the application.  Lines 22-27 in the attached script can be uncommented to illustrate this behavior.  These lines must be uncommented in addition to lines 18-20.
Comment 1 Brian Merrell 2009-04-14 07:00:48 UTC
Created attachment 285491 [details]
Script referenced in REPRO steps
Comment 2 Sanford Armstrong 2009-04-29 08:09:09 UTC
Fix pending review:
http://reviews.mono-a11y.org/r/168/
Comment 3 Sanford Armstrong 2009-04-29 17:03:02 UTC
Fixed in UIAutomationWinforms (trunk r133036, 1.0 r133037).
Comment 4 Feng Xia Mu 2009-06-08 03:44:44 UTC
when run the attached script, the application won't crash.

verify in:
mono-core-135601-1177.src.rpm
mono-uia-132785-276.src.rpm
uiaatkbridge-134036-662.src.rpm
uiautomationwinforms-134512-668.src.rpm
Revision: 135624