|
Bugzilla – Full Text Bug Listing |
| Summary: | InvalidOperationException when trying to launch columnheader.py sample | ||
|---|---|---|---|
| Product: | [Mono] UI Automation | Reporter: | Andres Aragoneses <aaragoneses> |
| Component: | Winforms - UIA | Assignee: | E-mail List <mono-a11y-bugs> |
| Status: | NEW --- | QA Contact: | E-mail List <mono-a11y-qa> |
| Severity: | Normal | ||
| Priority: | P5 - None | ||
| Version: | Unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Other | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
|
Description
Andres Aragoneses
2009-09-14 21:55:01 UTC
Threading bug (not deterministic). Published this patch in RB ( http://reviews.mono-a11y.org/r/450/diff/ ): Index: UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/FragmentControlProvider.cs =================================================================== --- UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/FragmentControlProvider.cs (revision 141771) +++ UIAutomationWinforms/UIAutomationWinforms/Mono.UIAutomation.Winforms/FragmentControlProvider.cs (working copy) @@ -149,7 +149,7 @@ public IEnumerator<FragmentControlProvider> GetEnumerator () { - foreach (FragmentControlProvider childProvider in children) + foreach (FragmentControlProvider childProvider in new List<FragmentControlProvider> (children)) yield return childProvider; } However, this led to a discussion in IRC: (03:55:43 PM) brad: knocte: hrm... I don't really see how this fixes the threading bug (03:55:58 PM) brad: yes, you're copying the children array, but it's still not thread safe (03:56:17 PM) brad: and copying the children array in GetEnumerator is going to be *really* expensive (03:56:45 PM) knocte: mmm (03:57:53 PM) knocte: I think it fixes the threading bug (I've seen code that does this) because it allows the collection to be modified while the copy is intact (03:58:02 PM) knocte: I'll check about the complexity though (03:58:21 PM) brad: unless the list is synchronized, copying the data while it is being modified could corrupt the data (03:59:05 PM) knocte: ok, then I didn't fix it completely; I fixed it for the case in which the data is being modified while inside the foreach loop, not while copying the data (03:59:17 PM) brad: yes, perhaps (03:59:36 PM) brad: but the right fix is to actually add locking (03:59:59 PM) knocte: but with what? the stacktrace doesn't give much more info (04:00:21 PM) knocte: with every member that access the collection? (04:01:19 PM) brad: well, I don't know about that specific instance (04:01:35 PM) brad: but modifying the children list while you're iterating it is a bad idea, if that is indeed what is happening (04:02:14 PM) brad: (again, I haven't seen the stack trace, so I can't comment on specifics) (04:02:30 PM) knocte: the stacktrace is on the bug referenced (04:03:43 PM) brad: eep... yeah, the only safe way to modify a list while you're iterating it is to iterate using indicies (04:04:22 PM) knocte: well, I would say, that may preven InvalidOperationExceptions, but would still cause IndexOutOfRangeExceptions (04:04:37 PM) knocte: or not, mm, not sure (04:04:49 PM) brad: if children is being modified as you're iterating it, yes (04:05:21 PM) brad: because you can't assume that once you check if the index is less than count, that that condition will exist during the block (04:05:38 PM) brad: thus, locking (04:06:05 PM) brad: *but* if you're modifying the children array while iterating, that's a different case (04:07:55 PM) knocte: ok, then as it's not trivial, let's write this on the bug and move on, this is in the end 1.0 work.. (04:09:20 PM) brad: nod So, as this is not trivial to fix, we're postponing it. |