Bug 16519 - Pasting into source editor breaks after a while
Summary: Pasting into source editor breaks after a while
Status: REOPENED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 4.2.x
Hardware: PC Windows
: High major
Target Milestone: Future Cycle (TBD)
Assignee: Cody Russell
URL:
: 17088 17734 18073 18968 21912 25553 32052 55133 ()
Depends on:
Blocks:
 
Reported: 2013-11-29 17:13 UTC by Mikayla Hutchinson [MSFT]
Modified: 2017-07-01 08:46 UTC (History)
19 users (show)

Tags: gtk
Is this bug a regression?: ---
Last known good build:


Attachments
logs from customer hitting bug (92.69 KB, application/zip)
2015-01-15 17:48 UTC, Kent Green [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 16519 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
REOPENED

Description Mikayla Hutchinson [MSFT] 2013-11-29 17:13:09 UTC
After a couple of times pasting from Chrome into the XS source editor, it breaks. It either pastes junk, or throws an exception:

System.ArgumentException: Source array was not long enough. Check srcIndex and length, and the array's lower bounds.
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at Mono.TextEditor.ClipboardActions.<>c__DisplayClass4.<PasteFrom>b__0(Clipboard clp, SelectionData selectionData)
   at GtkSharp.ClipboardReceivedFuncWrapper.NativeCallback(IntPtr clipboard, IntPtr selection_data, IntPtr data)
Comment 1 Mike Krüger 2013-12-02 08:39:15 UTC
If that happens from chrome -> xs it's a gtk bug.

That code only gets called for the MD_ATOM copy operation - it should fail if the clipboard doesn't contain a correct MD_ATOM content.
Comment 2 Mike Krüger 2013-12-02 08:55:56 UTC
btw. I can't repro that - do you've any hints ?
Comment 3 Mikayla Hutchinson [MSFT] 2013-12-02 15:10:09 UTC
Try pasting source from GitHub - not raw view. Raw view works fine,
Comment 4 Mike Krüger 2013-12-03 04:05:44 UTC
works for me - but that may be caused by my old gtk/gtk# version I use.
Comment 5 Mikayla Hutchinson [MSFT] 2014-01-07 22:08:28 UTC
*** Bug 17088 has been marked as a duplicate of this bug. ***
Comment 6 Mikayla Hutchinson [MSFT] 2014-01-16 18:44:52 UTC
FWIW I saw this when copying from a GtkTextView in GTK# 2.12.24:

ERROR [2014-01-16 18:43:22Z]: Gdk-Critical: inner_clipboard_window_procedure: assertion 'success' failed
Stack trace: 
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at MonoDevelop.Ide.IdeApp.Run() in c:\Users\Michael\vcs\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Ide\Ide.cs:line 394
   at MonoDevelop.Ide.IdeStartup.Run(MonoDevelopOptions options) in c:\Users\Michael\vcs\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Ide\IdeStartup.cs:line 295
   at MonoDevelop.Ide.IdeStartup.Main(String[] args, IdeCustomizer customizer) in c:\Users\Michael\vcs\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop.Ide\IdeStartup.cs:line 581
   at MonoDevelop.Startup.MonoDevelopMain.Main(String[] args) in c:\Users\Michael\vcs\monodevelop\main\src\core\MonoDevelop.Startup\MonoDevelop.Startup\MonoDevelopMain.cs:line 17
Comment 7 Mike Krüger 2014-03-03 03:19:06 UTC
*** Bug 18073 has been marked as a duplicate of this bug. ***
Comment 8 Mike Krüger 2014-03-03 03:19:44 UTC
I tried a work around - reopen if it happens again.

(I wasn't able to reproduce that bug)
Comment 9 David Karlaš 2014-04-10 03:29:24 UTC
This is still happening to me aprox. 1x per day.(but really depends on how much you want to copy-paste from outside MD)

More info: https://github.com/mono/monodevelop/commit/da56bdd9955f4057faa014f104315a4774834cca#commitcomment-5917365
Comment 10 Mikayla Hutchinson [MSFT] 2014-04-20 18:49:14 UTC
*** Bug 18968 has been marked as a duplicate of this bug. ***
Comment 11 David Karlaš 2014-04-21 03:59:56 UTC
I found kind of temporary work around. When pasting is failing press Ctrl+F(open search tab), Ctrl+V(paste text into search tab), Ctrl+A(select all text in search tab), Ctrl+C(copy all text from search tab), Esc(close search tab), Ctrl+V(paste in MD as you wanted in first place). Saved me several restarts I hope it helps others until this is resolved.
Comment 12 Matt Ward 2014-05-07 12:05:47 UTC
Another workaround for this that seems to work for me is to right click the tab at the top of the open text editor, then select Copy file path/name. Then you can copy text from the other application and paste it into the text editor again.
Comment 13 Matt Ward 2014-05-20 12:42:38 UTC
Is the following bug related?

https://bugzilla.xamarin.com/show_bug.cgi?id=17734
Comment 14 Mike Krüger 2014-05-20 13:29:13 UTC
*** Bug 17734 has been marked as a duplicate of this bug. ***
Comment 15 Mike Krüger 2014-05-20 13:31:17 UTC
Yes it is - the other bug has even more information about what's happening.

I do some very advanced clipboard operation (a custom format) which breaks for some reason on windows :/.

The funny thing is that I even wasn't able to repro it on windows. However if I would switch my daily work to windows that might change ... but in any case it's something inside gtk that doesn't do the right thing.
Comment 16 Cody Russell 2014-05-20 13:40:00 UTC
I was trying to reproduce this last week and was having trouble. Every time I would paste, it worked just fine. So I'm not sure if I was copying from the wrong source app (and maybe it was using a clipboard format that gtk understood) or what.

My dnd branch has a lot of clipboard format changes in gtk, but it's hard to tell if any of that work will help fix this since I can't reproduce it reliably.
Comment 17 Tyson 2014-05-20 18:32:05 UTC
I'd like to point out this bug has nothing to do with Chrome.  I experience copy/paste problems when using Xamarin Studio with:

Notepad
Notepad++
FireFox
Chrome
Visual Studio 2012
Another Copy of Xamarin Studio
THE SAME copy of Xamarin Studio (copying between tabs/files)

It usually manifests after the XS has been running for a couple hours, and your chances of encountering it increase the more copy/pasting you do.

Restarting XS seems to fix it.. for a while..
Comment 18 Kent Green [MSFT] 2014-05-20 19:04:02 UTC
For me, restarting XS doesn't help; and the only thing I've found XS accepts copy/paste from is itself. here's a demo of the bug: http://screencast.com/t/dgFrc3pHqOfT
Comment 19 Cody Russell 2014-05-20 19:10:03 UTC
If you happen to discover steps to reproduce this quickly and reliably when Xamarin Studio first starts, that would be an amazing help. So far it seems like everyone who hits this problem hits it after it's been running for some time.
Comment 20 Kent Green [MSFT] 2014-05-20 19:16:24 UTC
For me it happens as soon as it starts, I'm not able to copy/paste even in the beginning. I tend to run a lot of background programs, so maybe it's a sort of weird memory error? Though that would still seem odd since copy/paste actions should *usually* be fairly lightweight; wouldn't they?

I'll try rebooting in safe mode and experimenting with it then as soon as I finish an install I'm running.
Comment 21 Cody Russell 2014-05-20 21:59:23 UTC
Oh, interesting. Can you give me a little information about your setup?

Go to the "About Xamarin Studio" dialog (under help) and give me:

GTK# version (2.12.25 or something close to that)
Git revision (95ac543f or something)
What version of Windows you're using (and if it's 32- or 64-bit)

If I can, I'll try to setup a VM with the same version of Windows you have and try to reproduce your environment as best I can.
Comment 22 Tyson 2014-05-21 12:30:13 UTC
This morning's paste error:
Uptime: 32 minutes
OS: Windows 7 Professional SP1(64-bit)
XS Version: 4.2.5 (Build:0)
GTK+ 2.24.22 (MS-Windows theme)
GTK# 2.12.25

Opened XML Layout.  Positioned cursor inside of xml defining a control and typed android:gravity="top|left", selected text I had just typed, copied it, moved cursor to the XML defining the next control, and pressed CTRL-V.

Exception Throw:

System.ArgumentException: Source array was not long enough. Check srcIndex and length, and the array's lower bounds.
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at Mono.TextEditor.ClipboardActions.<>c__DisplayClass4.<PasteFrom>b__0(Clipboard clp, SelectionData selectionData)
   at GtkSharp.ClipboardReceivedFuncWrapper.NativeCallback(IntPtr clipboard, IntPtr selection_data, IntPtr data)
Comment 23 Tyson 2014-05-21 13:09:11 UTC
In addition (To comment 22):  
1. After exception was thrown, tried to paste into notepad: nothing happened (as if clipboard was empty).
2. Copied same content from XS again, and tried to paste into notepad: nothing happened, again.
3. Then tried to paste into XS: Exception thrown again.
4. Restart XS.
5. Problem is gone..
Comment 24 Tyson 2014-05-21 13:24:04 UTC
Another weird fix to the problem:

1. Get Exception trying to paste in XS.
2. Open notepad. type anything.  Copy it. Paste it in notepad.
3. Return to XS: Copy/Paste works again.
Comment 25 Kent Green [MSFT] 2014-05-22 12:26:23 UTC
A clue! I ran a bunch of general updates; mostly unrelated to XS as far as I can tell, I rebooted and closed any unneeded start-up programs, then ran XS and copy/paste worked. 

A little later I tested it again, and it didn't; so I tried closing programs and eventually discovered that it stops working whenever I have Chrome OR Internet Explorer open; even if no actual webpages are open, but just a blank tab. Upon having both browsers closed and waiting for a little bit copy paste works normally again; and then once I open either one it disappears in the same way. 

So my theory is that it's a problem caused by either interaction with either browser, or general memory related. I haven't found any non-browser applications that appear associated with the bug as of yet.

(Note: my bug is slightly different from what several people have noted; when I try to copy/paste, nothing happens at all, it's as though the clipboard is blank; there's not even an error message.)

Info you requested:
GTK# 2.12.25
Git revision: 89cfcdd28a9a64d4ddc606f8c4f8e6aaafad610a

Windows 7 64-bit
Comment 26 Tyson 2014-05-22 21:34:40 UTC
I kept track of what was running in the BG today.. 2 chromes, a firefox ( for sqlite tools), notepad++ and pgadmin (postgres GUI client)- all left open from yesterday (pc slept overnight but did not restart).  Intermittent use of a .net windows form app I wrote myself.

Not a single copy/paste problem all day.  Yesterday was so bad I almost switched to using visual studio.  My sympathies to whoever in currently in charge of this bug... it's incredibly random..
Comment 27 Kent Green [MSFT] 2014-05-27 16:55:34 UTC
The bug seems to have disappeared for me, I can copy paste again like normal. I downloaded the latest update earlier today, before I noticed it working again, even with plenty going on in the background. So I don't know if it's truly fixed or just gone into hiding; but it seems to work.

I'm using XS 5.0 (Build 876) where it seems to have been fixed.
Comment 28 Tyson 2014-05-27 18:04:06 UTC
Guess who just discovered the error log? This guy.

Taken DIRECTLY after an exception was thrown when trying to paste:

ERROR [2014-05-27 14:53:48Z]: An unhandled exception has occured. Terminating MonoDevelop? False
System.ArgumentException: Source array was not long enough. Check srcIndex and length, and the array's lower bounds.
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at Mono.TextEditor.ClipboardActions.<>c__DisplayClass4.<PasteFrom>b__0(Clipboard clp, SelectionData selectionData)
   at GtkSharp.ClipboardReceivedFuncWrapper.NativeCallback(IntPtr clipboard, IntPtr selection_data, IntPtr data)
ERROR [2014-05-27 14:56:53Z]: Got exception while creating markup for :[OperatorResolveResult System.String]
System.ArgumentNullException: Value cannot be null.
Parameter name: entity
   at MonoDevelop.CSharp.SignatureMarkupCreator.GetMarkup(IEntity entity)
   at MonoDevelop.SourceEditor.LanguageItemTooltipProvider.CreateTooltip(ToolTipData data, Int32 offset, Ambience ambience, ModifierType modifierState)
ERROR [2014-05-27 14:57:17Z]: Got exception while creating markup for :[OperatorResolveResult System.String]
System.ArgumentNullException: Value cannot be null.
Parameter name: entity
   at MonoDevelop.CSharp.SignatureMarkupCreator.GetMarkup(IEntity entity)
   at MonoDevelop.SourceEditor.LanguageItemTooltipProvider.CreateTooltip(ToolTipData data, Int32 offset, Ambience ambience, ModifierType modifierState)
INFO [2014-05-27 14:57:45Z]: CodeTemplateService: No user templates, reading default templates.
ERROR [2014-05-27 15:00:21Z]: Gdk-Critical: inner_clipboard_window_procedure: assertion 'success' failed
Stack trace: 
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at MonoDevelop.Ide.IdeApp.Run()
   at MonoDevelop.Ide.IdeStartup.Run(MonoDevelopOptions options)
   at MonoDevelop.Ide.IdeStartup.Main(String[] args, IdeCustomizer customizer)
   at Xamarin.Startup.MainClass.Main(String[] args)
Comment 29 Mikayla Hutchinson [MSFT] 2014-08-12 22:30:47 UTC
*** Bug 21912 has been marked as a duplicate of this bug. ***
Comment 30 Paul Read 2014-09-12 05:27:37 UTC
XS randomly stops accepting paste for me - though these are generally from Chrome.  REstarting XS does NOT fix it.
Restart PC isntead :-(
Comment 31 Tyson 2014-12-03 14:48:41 UTC
Wow.  This was fixed for about 4 months, but now the problem is showing up again intermittently.

Restarting Xamarin Studio fixed it for me.

Bug occured while copying text from Notepad++ into the source edittor window of Xamarin Studio.

I'd paste some logs but I can't determine which of the hundreds of errors being thrown are related to this particular problem....  I've had XS open for only 25 minutes and i have over 100KB of ide logs!!
Comment 32 Matt Ward 2015-01-09 07:57:58 UTC
*** Bug 25553 has been marked as a duplicate of this bug. ***
Comment 33 Kent Green [MSFT] 2015-01-15 17:48:15 UTC
Created attachment 9371 [details]
logs from customer hitting bug

From this desk case:
https://xamarin.desk.com/agent/case/116869

Customer reports hitting this issue with the following info:

"Error with copy paste happened between 16:44:00 and 16:45:30.

Copying between Outlook and Xamarin studio. Only client applications running Outlook, Xamarin Studio and Windows explorer. Studio been running for an hour or so.

Logs attached, hope it helps"
Comment 34 Dmitry 2015-03-16 02:27:09 UTC
When it happens, I try to copy some text and paste does not work. But if I copy text with 'next line' code (for example, 2 lines of text), then copy/paste will start to work correctly.
Comment 35 MrSmith 2015-03-24 21:30:46 UTC
Frustrating for our developers. This issue is stilling happening in v5.7.2 Build 7. It seems to be happening more often ever since i've upgraded.

Do you need any more evidence to address this issue? If so, we are more than happy to assist. Just please fix this, as it is very annoying to have to restart the IDE ever 15 minutes just to get copy/paste support from an external source into Xamarin Studio.
Comment 36 Mike Krüger 2015-07-17 00:18:33 UTC
*** Bug 32052 has been marked as a duplicate of this bug. ***
Comment 37 MrSmith 2015-08-13 14:26:57 UTC
Still happening in v5.9.5 Build 9.
OS: Windows 8.1 64-bit

Is this the correct path below? If so, what information do you need me to retrieve? This defect has gone on for far too long

C:\Users\%username%\appdata\Local\XamarinStudio-5.0\Logs\
Comment 39 Matt Ward 2017-04-13 10:43:59 UTC
*** Bug 55133 has been marked as a duplicate of this bug. ***
Comment 40 fdefoy 2017-05-17 15:39:09 UTC
Seriously, will this bug ever get fixed?

Im on Windows 10, was on 7 before and every single time I open MD copy paste stops working within minutes.

I have the version that comes with Unity 5.6. I know there are newer versions, but unity is probably one of the largest exposure MD gets and its a shame that something as simple yet indispensable has been literally broken for years versions after versions after versions.

If I knew more about GTK id try to fix it but I dont so would some of you devs at least share the info you have on this issue so we can try to get this working?

Its so bad that Unity as started bundling VS, its probably a matter of time before MD is shown the way out if this keeps going on.
Comment 41 Neocriss 2017-07-01 08:46:46 UTC
This bug is appearing in Xamarin/Visual Studio on Mac when the keyboard language is switched to different from English.