Bug 17631 - Xamarin froze from time to time when Typing comments or string of chars in Japanese
Summary: Xamarin froze from time to time when Typing comments or string of chars in Ja...
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 4.3.0
Hardware: Macintosh Mac OS
: High critical
Target Milestone: 5.0
Assignee: Cody Russell
URL:
: 17738 18241 18385 18446 20255 ()
Depends on:
Blocks:
 
Reported: 2014-02-06 03:18 UTC by Cyril Perissol
Modified: 2014-06-02 16:40 UTC (History)
12 users (show)

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

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Cyril Perissol 2014-02-06 03:18:38 UTC
I started to work with Xamarin Studio to develop android and ios app a few weeks ago and I am encountering lot of problem using Japanese in Xamarin Studio. When typing Japanese characters as comments or data for strings, very often Xamarin studio froze and I have to force the application to quit. 
Example of Comments or codes type in Japanese:

/*確認してください*/

string mystring = "日本語";
Basically, it will freeze in the middle of typing the Japanese sentence. If you refer to the upper example it will stop /*確認してくだ*/

Very frustrating.
I am the only one to have this issue? Xamarin Studio: 4.3.2 (Version 2) MacOS X 10.9.1

If you have no knowledge of Japanese it could be difficult to debug. Anyway, I hope you can solve that quickly since I am forcing myself to not use Japanese to avoid crashes. 

Just a hint on Japanese input. It's in phonetic so if I type japan in Japanese in latin later I will hit "nihon" which will appear as にほん in Japanese phonetic alphabet which will appear underlined until I validate the final ideogram 日本 (nihon). I chose the final ideogram by pressing space while the characters are underlined. Nihon could be written as 日本 or 二本 etc.

I hope it helps.

Best regards,

Cyril
Comment 1 Prashant manu 2014-02-06 04:00:07 UTC
We have checked this issue and observing same behavior while Typing comments or string of chars in Japanese. 
Screencast for this: http://screencast.com/t/Kik7ZRQP

Supplement Info:
Crash Log: https://gist.github.com/saurabh360/438418f9fd0e066bfb1d

Environment Info:
All MAC
XS 4.2.2 (build 2)
Xam.iOS 7.0.6-168
Xam.Android 4.10.1-68
Comment 2 Cody Russell 2014-02-06 19:46:47 UTC
I think I need to try to talk to Mike Krüger about this. TextArea.cs is implementing a lot of custom IM stuff and I don't understand it just yet. In particular I don't understand the "lastIMEventMappedChar" stuff or the UTF32 stuff (both in IMCommit()). Also in OnKeyPressEvent(), basically everything under the "FIXME: why are we doing this?" comment.

For comparison I was looking at the way GtkTextView and GtkEntry interact with GtkIMContext and they seem much simpler, and this issue doesn't occur with either of them.

I tried setting up Japanese input on my Windows machine to compare with, but apparently the input there works completely different than Mac and I wasn't able to test that yet.
Comment 3 Mikayla Hutchinson [MSFT] 2014-02-07 16:22:17 UTC
Cody, I'm pretty sure TextArea is not at fault here. It's a crash in the im-quartz module.

47 gtk_im_context_filter_keypress + 256 (libgtk-quartz-2.0.0.dylib) [0x544dc50]
47 gtk_im_multicontext_filter_keypress + 85 (libgtk-quartz-2.0.0.dylib) [0x5452405]
47 gtk_im_context_filter_keypress + 256 (libgtk-quartz-2.0.0.dylib) [0x544dc50]
47 quartz_filter_keypress + 547 (im-quartz.so) [0x12efb463]
47 output_result + 499 (im-quartz.so) [0x12efb223]
47 g_free + 46 (libglib-2.0.0.dylib) [0x520d64e]
47 free + 428 (libsystem_c.dylib) [0x939dce03]
47 abort + 168 (libsystem_c.dylib) [0x939fa631]
47 ??? [0xffffffff]
47 _sigtramp + 43 (libsystem_c.dylib) [0x939ae94b]
47 sigabrt_signal_handler + 109 (libmonosgen-2.0.dylib) [0x10fed0d]
47 mono_handle_native_sigsegv + 498 (libmonosgen-2.0.dylib) [0x10a8c02]
47 __wait4 + 10 (libsystem_kernel.dylib) [0x97fdc09a]
*47 ??? (mach_kernel + 3613728) [0xffffff8000572420]
Comment 4 Cody Russell 2014-02-07 16:30:40 UTC
I see that. The g_free() that's causing this does not have a NULL check before it, but adding one didn't fix it. I saw something about trying to free memory that wasn't allocated.

I'm also seeing this error:

ERROR [2014-02-07 15:27:17Z]: Gtk-Critical: gtk_im_context_get_preedit_string: assertion `str == NULL || g_utf8_validate (*str, -1, NULL)' failed

This was the thing that led me to start looking into TextArea.cs and comparing it to GtkTextView and GtkEntry. It looks like we're sending invalid UTF8 to the IM context. I don't know if this is related to the g_free() yet (there are actually two different stack traces I'm seeing when typing Japanese into XS, but I don't remember the difference in steps to trigger each one).
Comment 5 Mikayla Hutchinson [MSFT] 2014-02-07 16:52:40 UTC
The only place we "send" any text to the IMContext is the response to its RetrieveSurrounding request, and P/Invoke should be handling the UTF16->UTF8 conversion there. The only other thing we give to it is raw GTK key events.
Comment 6 Mikayla Hutchinson [MSFT] 2014-02-12 22:11:59 UTC
*** Bug 17738 has been marked as a duplicate of this bug. ***
Comment 7 Michael Herring 2014-02-26 01:57:58 UTC
This is happening with Korean text too, for what it's worth, and I didn't encounter it until upgrading Mono. 

If I uninstall Mono, then reinstall 3.2.5, I can type CJK text with no problem in the latest version of Xamarin Studio.

This leads me to believe that something has changed at a level beneath XS that's causing this crash.
Comment 8 taiga.nakayama 2014-03-02 19:13:22 UTC
Thank you for the great information.

My Xamarin Studio doesn't crash using Mono.Framework 3.2.4.
(I couldn't download 3.2.5)
Comment 9 Michael Herring 2014-03-03 08:28:17 UTC
For some reason, 3.2.5 has disappeared from the Mono archives page. I still have the archive, though, and I can confirm it also does not crash.
Comment 10 Mikayla Hutchinson [MSFT] 2014-03-07 14:11:43 UTC
*** Bug 18241 has been marked as a duplicate of this bug. ***
Comment 11 Cody Russell 2014-03-10 00:50:37 UTC
Fixed in bockbuild b6cc7215c007c9068000f68db0edf5a86052bf2d
Comment 12 taiga.nakayama 2014-03-10 03:26:45 UTC
Hi Cody,

When and how can I use it?
Comment 13 Michael Herring 2014-03-10 04:52:40 UTC
I tried to go to wrench.mono-project.com to find this build but I can't find a place to actually input this hash. There's no indication whether it's a fix in GTK, Mono or Xamarin Studio, so I can't look on Github to find it, either. 

Where do we go to find this commit, or a build that has it? (and/or, what's the development status of XS 5.0, since that seems to be the targeted release?)
Comment 14 Marius Ungureanu 2014-03-10 10:21:09 UTC
@Michael: This actually means bockbuild repository on GitHub: https://github.com/mono/bockbuild/commit/b6cc7215c007c9068000f68db0edf5a86052bf2d
Comment 15 Cody Russell 2014-03-11 14:32:33 UTC
Taiga, this should become available in the next Mono release for Mac, but I'm not exactly sure when that will be. I tried asking around yesterday for you but I wasn't able to get a good answer. If I learn more then I'll try to comment on here and keep you updated.

If you really can't wait, you could try building gtk out of bockbuild and copying im-quartz.* into your Mono directory. I don't really recommend doing that normally, but I expect that this bug may be causing you a lot of problems. If you decide you need to build this instead of waiting for the Mono release then send me an email cody@xamarin.com and I can try to help walk you through the steps.
Comment 16 taiga.nakayama 2014-03-11 21:40:10 UTC
Cody, thank you for the detail.

I'm using version 3.2.4 of Mono.Framework, and I can use Xamarin Studio not having it crashed.
So I will wait for the new release of Mono.

Thank you again.
Comment 17 Mikayla Hutchinson [MSFT] 2014-03-19 03:08:56 UTC
*** Bug 18446 has been marked as a duplicate of this bug. ***
Comment 18 Mikayla Hutchinson [MSFT] 2014-04-06 21:49:21 UTC
*** Bug 18385 has been marked as a duplicate of this bug. ***
Comment 19 Prashant manu 2014-04-11 04:58:01 UTC
Now XS doesn't froze when Typing comments or string of chars in Japanese.
Screencast for this: http://screencast.com/t/zigvLBMZ

Environment Info:
All MAC
Xamarin Studio Version 5.0 (build 677)
Build Information
Git revision: 29bce5a75b22d8f6982f6503ba3ab2f8ae5cac64
Xamarin addins: 6ed2bd55923e1afa9b11c5bb5294cdea3ccebc20
Xamarin.iOS Version: 7.2.1.212 
Hash: 26fcde2
Mono 3.4.0 ((no/9761a75)
Xam.Android 4.12.4.6
Comment 20 Mikayla Hutchinson [MSFT] 2014-06-02 16:40:28 UTC
*** Bug 20255 has been marked as a duplicate of this bug. ***