Bug 13442 - Crash if you enable "International Codesets" and compile with LLVM
Summary: Crash if you enable "International Codesets" and compile with LLVM
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-07-24 15:45 UTC by Adrian Gallero
Modified: 2014-01-21 13:30 UTC (History)
4 users (show)

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


Attachments
An app showing the issue, in case that it is needed. Run it in a device, RELEASE mode (so it uses LLVM) (5.94 KB, application/zip)
2013-07-24 15:45 UTC, Adrian Gallero
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 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 Adrian Gallero 2013-07-24 15:45:57 UTC
Created attachment 4424 [details]
An app showing the issue, in case that it is needed. Run it in a device, RELEASE mode (so it uses LLVM)
Comment 1 Adrian Gallero 2013-07-24 16:08:26 UTC
Sorry, I made one mistake. 

The international settings are configuration dependent, so I had set it in "DEBUG", but in the "RELEASE" configuration it wasn't. If you add it, then it works.

It is sadly half of the problem though, because it shouldn't completely crash if you try to access an encoding that doesn't exist, it should raise an Exception that we should be able to catch.
Comment 2 Adrian Gallero 2013-07-28 20:16:19 UTC
Well, after looking at this bug again, I see that the description I had originally written was replaced by the "attachment description", so it isn't clear what this is about.

The bug (as corrected by comment 1) is: If you use  Encoding.GetEncoding anywhere in your app, and you didn't check the correct "internaltional codeset" from the project options, the application will crash with a sigfault. It should throw an Exception if the encoding is not found.
Comment 3 Zoltan Varga 2013-07-29 04:10:06 UTC
The app throws an unhandled exception in TestSwitching(), thats why it crashes. The console contains the exception message:

Jul 29 10:09:14 Zoltan-Vargas-iPad TestBigSwitch[5592] <Warning>: Unhandled managed exception: CodePage 1252 not supported (System.NotSupportedException)
at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in <filename unknown>:0
at TestBigSwitch.TestBigSwitchViewController.TestSwithing (MonoTouch.Foundation.NSObject sender) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0
at TestBigSwitch.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 4 Adrian Gallero 2013-07-29 05:07:38 UTC
Hi,

Thanks for the explanation.
 
My main problem is that I am developing a component for the App store, which needs code page 1252. I can (and will) explain in the readme that you need to enable the codepages in the app using the library, but it isn't a good "out of the shelf" experience if you create a new app, do some simple calls to the component, and the app disappears. This is why I would like to show a friendlier message, and I'd like the debugger to stop in the line with the problem

If this can't be fixed, is there a way to check in my code if the code pages are enabled so I can throw my own exception?

Thanks again,
   Adrian.
Comment 5 Zoltan Varga 2013-07-29 06:09:15 UTC
You can catch the exception thrown by GetEncoding (), or is that not working ?
Comment 6 Adrian Gallero 2013-07-29 06:29:55 UTC
No, catching it doesn't seem to work.

the following code:

       partial void test(NSObject sender)
        {
            try
            {
                Encoding.GetEncoding(1512);
             with
            catch
            {
                Console.WriteLine("Encoding not supported");
            }
        }

even when running in the simulator, will just kill the application.



Unhandled Exception:
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[encodingViewController dotest:]: unrecognized selector sent to instance 0xb443a20
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at encoding.Application.Main (System.String[] args) [0x00008] in /Users/adrian/Projects/encoding/encoding/Main.cs:16 
2013-07-29 07:28:55.623 encoding[68119:c07] Unhandled managed exception: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[encodingViewController dotest:]: unrecognized selector sent to instance 0xb443a20 (MonoTouch.Foundation.MonoTouchException)
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at encoding.Application.Main (System.String[] args) [0x00008] in /Users/adrian/Projects/encoding/encoding/Main.cs:16 
mono-rt: Stacktrace:


mono-rt: 
Native stacktrace:


mono-rt: 	0   encoding                            0x000b0b6a mono_handle_native_sigsegv + 266

mono-rt: 	1   encoding                            0x000bd3cd sigabrt_signal_handler + 109

mono-rt: 	2   libsystem_c.dylib                   0x921a58cb _sigtramp + 43

mono-rt: 	3   ???                                 0xffffffff 0x0 + 4294967295

mono-rt: 	4   libsystem_sim_c.dylib               0x0425d57b abort + 140

mono-rt: 	5   encoding                            0x00233d0b monotouch_unhandled_exception_handler + 283

mono-rt: 	6   encoding                            0x000ad9a7 mono_invoke_unhandled_exception_hook + 231

mono-rt: 	7   encoding                            0x000b208a mono_handle_exception_internal + 4170

mono-rt: 	8   encoding                            0x000b21d9 mono_handle_exception + 41

mono-rt: 	9   encoding                            0x000552ad mono_x86_throw_exception + 285

mono-rt: 	10  ???                                 0x0b576e8f 0x0 + 190279311

mono-rt: 	11  encoding                            0x00233dfe monotouch_exception_handler + 158

mono-rt: 	12  CoreFoundation                      0x01422318 __handleUncaughtException + 728

mono-rt: 	13  libobjc.A.dylib                     0x0409a0b9 _ZL15_objc_terminatev + 86

mono-rt: 	14  libc++abi.dylib                     0x043dba65 _ZL19safe_handler_callerPFvvE + 13

mono-rt: 	15  libc++abi.dylib                     0x043dbacd __cxa_bad_typeid + 0

mono-rt: 	16  libc++abi.dylib                     0x043dcc4e __cxa_current_exception_type + 0

mono-rt: 	17  libobjc.A.dylib                     0x04099fbd objc_exception_rethrow + 47

mono-rt: 	18  CoreFoundation                      0x0133ef98 CFRunLoopRunSpecific + 360

mono-rt: 	19  CoreFoundation                      0x0133ee1b CFRunLoopRunInMode + 123

mono-rt: 	20  GraphicsServices                    0x04d8e7e3 GSEventRunModal + 88

mono-rt: 	21  GraphicsServices                    0x04d8e668 GSEventRun + 104

mono-rt: 	22  UIKit                               0x0279affc UIApplicationMain + 1211

mono-rt: 	23  ???                                 0x0c7e21aa 0x0 + 209592746

mono-rt: 	24  ???                                 0x0c7e041c 0x0 + 209585180

mono-rt: 	25  ???                                 0x0c7dff98 0x0 + 209584024

mono-rt: 	26  ???                                 0x0c7e00d7 0x0 + 209584343

mono-rt: 	27  encoding                            0x000de885 mono_jit_runtime_invoke + 741

mono-rt: 	28  encoding                            0x0018496e mono_runtime_invoke + 126

mono-rt: 	29  encoding                            0x00188974 mono_runtime_exec_main + 420

mono-rt: 	30  encoding                            0x00188ce5 mono_runtime_run_main + 725

mono-rt: 	31  encoding                            0x0004d245 mono_jit_exec + 149

mono-rt: 	32  encoding                            0x002213f4 main + 1988

mono-rt: 	33  encoding                            0x00003595 start + 53

mono-rt: 
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
Comment 7 Zoltan Varga 2013-07-29 07:16:52 UTC
Can you attach that project which crashes like this ?
Comment 8 Adrian Gallero 2013-07-30 09:38:13 UTC
Hi,

My last comment seems to not have appeared. I was saying that I've retested this in the latest stable version and it is working fine, no crashes but just an unhandled exception. 

So this one can be closed.

Thanks and sorry for the lost time, the report was made actually 1 day before the new version was released.
Comment 9 Zoltan Varga 2013-07-30 09:53:11 UTC
-> FIXED.
Comment 10 Akhilesh kumar 2014-01-21 13:30:38 UTC
As per Adrian's comment 8, this is working fine now.

Hence closing this issue.