Bug 60819 - Exception when pasting data into TextBox
Summary: Exception when pasting data into TextBox
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-11-23 02:38 UTC by Arsen.Shnurkov
Modified: 2017-12-06 05:04 UTC (History)
1 user (show)

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


Attachments
wraps the exception with try-catch block (1.24 KB, patch)
2017-12-06 04:54 UTC, Arsen.Shnurkov
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 60819 on GitHub or Developer Community 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: GitHub Markdown or Developer Community HTML
  • 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:
NEW

Description Arsen.Shnurkov 2017-11-23 02:38:37 UTC
If I insert ascii data everything works ok, but if I am trying to insert national characters (like "ёёёё"), program crashes:

System.ExecutionEngineException: String conversion error: Partial byte sequence encountered in the input.
  at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.PtrToStringAnsi(intptr)
  at System.Windows.Forms.XplatUIX11.TranslatePropertyToClipboard (System.IntPtr property) [0x000f2] in /var/tmp/portage/dev-lang/mono-5.9.0.398/work/mono-5.9.0.398-abi_x86_64.amd64/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:1284 
  at System.Windows.Forms.XplatUIX11.UpdateMessageQueue (System.Windows.Forms.XEventQueue queue, System.Boolean allowIdle) [0x00924] in /var/tmp/portage/dev-lang/mono-5.9.0.398/work/mono-5.9.0.398-abi_x86_64.amd64/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:1930 
  at System.Windows.Forms.XplatUIX11.ClipboardRetrieve (System.IntPtr handle, System.Int32 type, System.Windows.Forms.XplatUI+ClipboardToObject converter) [0x0002f] in /var/tmp/portage/dev-lang/mono-5.9.0.398/work/mono-5.9.0.398-abi_x86_64.amd64/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIX11.cs:2817 
  at System.Windows.Forms.XplatUI.ClipboardRetrieve (System.IntPtr handle, System.Int32 type, System.Windows.Forms.XplatUI+ClipboardToObject converter) [0x00000] in /var/tmp/portage/dev-lang/mono-5.9.0.398/work/mono-5.9.0.398-abi_x86_64.amd64/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUI.cs:567 
  at System.Windows.Forms.Clipboard.GetDataObject (System.Boolean primary_selection) [0x00039] in /var/tmp/portage/dev-lang/mono-5.9.0.398/work/mono-5.9.0.398-abi_x86_64.amd64/mcs/class/System.Windows.Forms/System.Windows.Forms/Clipboard.cs:390 
  at System.Windows.Forms.Clipboard.GetDataObject () [0x00000] in /var/tmp/portage/dev-lang/mono-5.9.0.398/work/mono-5.9.0.398-abi_x86_64.amd64/mcs/class/System.Windows.Forms/System.Windows.Forms/Clipboard.cs:137
Comment 1 Arsen.Shnurkov 2017-12-06 03:06:25 UTC
If I do 
xsel -b -o | xsel -b -i
before pasting, then everything is pasted without crash
Comment 2 Arsen.Shnurkov 2017-12-06 04:41:55 UTC
https://github.com/mono/mono/blob/master/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIX11GTK.cs#L779
NetAtoms [(int)NA.OEMTEXT] = XInternAtom (DisplayHandle, "COMPOUND_TEXT", false);

COMPOUND_TEXT:
https://www.x.org/releases/X11R7.6/doc/xorg-docs/specs/CTEXT/ctext.html

it's not the Ascii !
Comment 3 Arsen.Shnurkov 2017-12-06 04:47:42 UTC
https://msdn.microsoft.com/en-us/library/cc231241.aspx

ANSI strings refer to multi-byte strings in which the encoding is controlled by the current system code page.
The way in which a Unicode string is converted to or from an ANSI string is implementation specific.
In the occasional case in which the server cannot convert from Unicode to ANSI, the operation MUST fail.
Comment 4 Arsen.Shnurkov 2017-12-06 04:54:55 UTC
Created attachment 25918 [details]
wraps the exception with try-catch block
Comment 5 Arsen.Shnurkov 2017-12-06 05:04:49 UTC
the true reason of why the "String conversion error" happens remains unknown...