This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 41358 - Xamarin Stuidio crashed on add GTK# widget signal handler
Summary: Xamarin Stuidio crashed on add GTK# widget signal handler
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor (show other bugs)
Version: 6.0.0 (C7)
Hardware: PC All
: High critical
Target Milestone: C7SR1
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2016-05-27 14:33 UTC by Alexander Ivanov
Modified: 2016-07-13 17:12 UTC (History)
8 users (show)

See Also:
Tags: DefectEscapeReview_Done
Is this bug a regression?: Yes
Last known good build: XS 5.10.3.51


Attachments
Log with exception (14.16 KB, text/plain)
2016-05-27 15:08 UTC, Alexander Ivanov
Details

Description Alexander Ivanov 2016-05-27 14:33:29 UTC
# Steps to reproduce
1. Create GTK# project
2. Open MainWindow in Designer
3. Select MainWindow Properties
4. On Signals tab double click any signal on "Click here to add a new handler", SetFocus for example
# Expected behavior
Default handler created. 

# Actual behavior
MessageBox: A fatal error has occured. Details of this error have been automatically sent to Xamarin for analysis. Xamarin sutdio will now close. OK
On OK click Xamarin Studio closed and windows standard application error window appears.

# Supplemental info (logs, images, videos)
Unhandled exception "System.InvalidOperationException" in mscorlib.dll
Operation not supported in background thread

# Test environment (full version information)
Xamarin Studio Community
Version 6.0 (build 5166)
Installation UUID: 4d02b5d3-c044-43a7-80fe-4b592fdac3c4
Runtime:
	Microsoft .NET 4.0.30319.42000
	GTK+ 2.24.26 (Light theme)
	GTK# 2.12.38

Xamarin.Profiler
Not Installed

Xamarin.Android
Not Installed

Xamarin Android Player
Not Installed

Build Information
Release ID: 600005166
Git revision: ec4f06cfaa9debdca2539e19edeafffe88ccd0cc
Build date: 2016-05-20 19:10:40-04
Xamarin addins: c7761d054f38e9a210822aba6356398af0c36fa9
Build lane: monodevelop-windows-cycle7

Operating System
Windows 6.1.7601.65536 (64-bit)
Comment 1 Matt Ward 2016-05-27 14:44:55 UTC
Can you attach the IDE logs with the exception in it? (Help - Open Log Directory). Thanks.
Comment 2 Alexander Ivanov 2016-05-27 15:08:34 UTC
Created attachment 16121 [details]
Log with exception
Comment 3 Luis Aguilera 2016-05-27 16:06:54 UTC
as logs have been provided, changing status back to new.
Comment 5 Alexander Ivanov 2016-06-09 15:11:18 UTC
Confirmed the issue in current stable:

Xamarin Studio Community
Version 6.0 (build 5174)
Installation UUID: 4d02b5d3-c044-43a7-80fe-4b592fdac3c4
Runtime:
	Microsoft .NET 4.0.30319.42000
	GTK+ 2.24.26 (Light theme)
	GTK# 2.12.38

Xamarin.Profiler
Not Installed

Xamarin.Android
Not Installed

Xamarin Android Player
Not Installed

Build Information
Release ID: 600005174
Git revision: 694a75f040b7f2309bc43d4f78a3a6572ca898bf
Build date: 2016-06-01 17:11:00-04
Xamarin addins: 33f406fa2dcf214012c78cb846585f062b2e1d24
Build lane: monodevelop-windows-cycle7-baseline

Operating System
Windows 6.1.7601.65536 (64-bit)
Comment 6 Michael Payne 2016-06-11 21:11:27 UTC
this is happening with me as well.
Comment 7 Matt Ward 2016-06-13 17:21:15 UTC
From the log:

System.InvalidOperationException: Operation not supported in background thread
   в MonoDevelop.Core.Runtime.AssertMainThread() в C:\Users\builder\data\lanes\2921\ec4f06cf\source\monodevelop\main\src\core\MonoDevelop.Core\MonoDevelop.Core\Runtime.cs:строка 441
   в MonoDevelop.Ide.Editor.TextEditor.OpenUndoGroup() в C:\Users\builder\data\lanes\2921\ec4f06cf\source\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Ide.Editor\TextEditor.cs:строка 411
   в MonoDevelop.Ide.TypeSystem.MonoDevelopWorkspace.<ApplyDocumentTextChanged>d__70.MoveNext() в C:\Users\builder\data\lanes\2921\ec4f06cf\source\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Ide.TypeSystem\MonoDevelopWorkspace.cs:строка 778

So what is happening is:

1) MonoDevelop.GtkCore.GuiBuilder.CodeBinder calls CodeGenerationService.AddNewMember on the UI thread.
2) CodeGenerationService.AddNewMember uses ConfigureAwait (false) and then calls
MonoDevelopWorkspace.TryApplyChanges on a non-UI thread.
3) MonoDevelopWorkspace.ApplyDocumentTextChanged is called on a non-UI thread.
4) ApplyDocumentTextChanged then opens the undo group for the text editor.
    using (var undo = editor.OpenUndoGroup ()) {
5) TextEditor.OpenUndoGroup verifies the thread is the UI thread, which it is not, and causes an exception to be thrown.

https://github.com/mono/monodevelop/blob/monodevelop-6.0.0.5174/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs#L779

Looking at the ApplyDocumentTextChanged code there is RunInMainThread a bit lower in that method. So I assume that RunInMainThread should instead called before the OpenUndoGroup method is called.
Comment 8 xamarin-release-manager 2016-06-14 09:04:50 UTC
Fixed in version 6.1.0.4640 (master)

Author: Mike Kr??ger
Commit: 421244e34adf01c09a1a92d39fca8d999cdfbb9f (mono/monodevelop)
Comment 9 xamarin-release-manager 2016-06-14 09:21:45 UTC
Fixed in version 6.0.2.4 (cycle7)

Author: Lluis Sanchez
Commit: df7ef9501a1785f6497d612ece561c3108a33421 (mono/monodevelop)
Comment 10 xamarin-release-manager 2016-06-15 18:45:58 UTC
Fixed in version 6.0.2.19 (cycle7-app-insights-rebased)

Author: Lluis Sanchez
Commit: df7ef9501a1785f6497d612ece561c3108a33421 (mono/monodevelop)
Comment 11 Mohit Kheterpal 2016-06-21 18:32:43 UTC
I have checked this issue with cycle7-app-insights-rebased version 6.0.2.23 and observed that this issue has been fixed as shown in screencast : http://www.screencast.com/t/UqoxkTHB

Hence closing this issue.

Thanks
Comment 12 Michael Payne 2016-06-22 02:14:44 UTC
where can i download that update? I've updated to xamarin studio 6.1, are we talking about a different product? I'm confused here.
Comment 13 Mike Krüger 2016-06-22 05:24:16 UTC
It's not released yet - the only way getting it ASAP is building from source.


However manually adding widget event handlers via source code is the easiest way for now.

Note You need to log in before you can comment on or make changes to this bug.