Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinForms applications crash when a specific text is pasted into any control that can accept text. #18923

Open
Calmarius opened this issue Feb 18, 2020 · 3 comments

Comments

@Calmarius
Copy link

I just wanted to paste a piece text from Wikipedia in a Winforms application.

A similar bug reported in the xamarin bug tracker but no progress with it since 2017: https://xamarin.github.io/bugzilla-archives/60/60819/bug.html

Steps to Reproduce

  1. Paste following text into any RichTextControl, Textbox or anything that accepts pasted text: "Benzo[a]pyrene is a polycyclic aromatic hydrocarbon and the result of incomplete combustion of organic matter at temperatures between 300 °C (572 °F) and 600 °C (1,112 °F). The ubiquitous compound can be found in coal tar, tobacco smoke and many foods, especially grilled meats. " in a Winforms application. It even crashes if you paste into a file open dialog.

Apparently the issue is with the ° mark.

Current Behavior

It crashes.

Expected Behavior

It doesn't crash and is able to handle the conversion (even if that means including a � instead.)

On which platforms did you notice this

[ ] macOS
[ X ] Linux
[ ] Windows

Version Used:

Mono JIT compiler version 6.8.0.105 (tarball Tue Feb 4 21:20:20 UTC 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(610)
Suspend: hybrid
GC: sgen (concurrent by default)

Stacktrace

System.ExecutionEngineException: String conversion error: Illegal byte sequence encounted in the input.
  at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.PtrToStringAnsi(intptr)
  at System.Windows.Forms.XplatUIX11.TranslatePropertyToClipboard (System.IntPtr property) [0x0005f] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.XplatUIX11.UpdateMessageQueue (System.Windows.Forms.XEventQueue queue, System.Boolean allowIdle) [0x00919] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.XplatUIX11.ClipboardRetrieve (System.IntPtr handle, System.Int32 type, System.Windows.Forms.XplatUI+ClipboardToObject converter) [0x0002f] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.XplatUI.ClipboardRetrieve (System.IntPtr handle, System.Int32 type, System.Windows.Forms.XplatUI+ClipboardToObject converter) [0x00000] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.Clipboard.GetDataObject (System.Boolean primary_selection) [0x00039] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.Clipboard.GetDataObject () [0x00000] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.TextBoxBase.ProcessKey (System.Windows.Forms.Keys keyData) [0x000a4] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.TextBoxBase.WndProc (System.Windows.Forms.Message& m) [0x0005b] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.TextBox.WndProc (System.Windows.Forms.Message& m) [0x0011c] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x0000b] in <69e4940ac30645898b9c63f67c310dba>:0 
  at System.Windows.Forms.NativeWindow.WndProc (System.IntPtr hWnd, System.Windows.Forms.Msg msg, System.IntPtr wParam, System.IntPtr lParam) [0x00085] in <69e4940ac30645898b9c63f67c310dba>:0 
@kijato
Copy link

kijato commented Feb 25, 2020

What is the difference between ° and ℃?

Char	Dec	Hex	Entity	Name
°	176	00B0	&deg;	DEGREE SIGN
℃	8451	2103	 	DEGREE CELSIUS

@jasonleenaylor
Copy link
Contributor

We are also seeing this problem with pasting in our WinForms application with a variety of valid Unicode characters. We didn't have this problem in earlier versions of Mono.

@AndreasRoland
Copy link

After facing the same problem while pasting text into keepass using mono in OpenSuse, I've had a quick look at mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIX11GTK.cs
I suppose the bug is in TranslatePropertyToClipboard at line 990 and 998.
My guess is that in line 996 PtrToStringAnsi is used correctly, but in line 990 PtrToStringAuto should be used and in line 998 PtrToStringUni.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants