[MonoTouch] SIGSEGV while executing native code

Guido Van Hoecke guivho at gmail.com
Fri Oct 7 06:59:11 EDT 2011


On Fri, Oct 7, 2011 at 12:56, Guido Van Hoecke <guivho at gmail.com> wrote:
> Can somebody explain following error?
>
> I get sigsegv errors in an app under development. I separated the
> 'offending' code to demonstrate the problem. Just create a new
> empty monotouch project and replace the FinishedLaunching method:
>
>        public override bool FinishedLaunching (UIApplication app,
> NSDictionary options)
>        {
>            window = new UIWindow (UIScreen.MainScreen.Bounds);
>            var view = new  UIView(UIScreen.MainScreen.Bounds);
>            var label = new UILabel(new RectangleF(0, 0,
> view.Bounds.Size.Width, view.Bounds.Size.Height));
>            label.TextAlignment = UITextAlignment.Center;
>            label.Text = "hi there";
>            view.AddSubview(label);
>            var toolBar = new UIToolbar (
>                new RectangleF(0, view.Bounds.Size.Height - 44f,
> view.Bounds.Size.Width, 44f));
>            var button = new UIBarButtonItem {
>                Title = "button",
>                Style = UIBarButtonItemStyle.Bordered };
>            button.Clicked += delegate {
>                using (var alert = new UIAlertView {Title = "alert",
> Message = "message" }) {
>                    alert.AddButton("yes");
>                    alert.AddButton("no");
>                    alert.Clicked += delegate(object sender,
> UIButtonEventArgs e) {
>                        if (e.ButtonIndex == 0) {
>                            label.Text = "we got a 'yes'";
>                        } else {
>                            label.Text = "too bad...";
>                        }
>                    };
>                    alert.Show();
>                }
>            };
>            var flex = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
>            toolBar.SetItems(new[] {flex, button, flex}, false);
>            view.AddSubview(toolBar);
>            window.AddSubview (view);
>            window.MakeKeyAndVisible ();
>            return true;
>        }
>
> When you run this app from MD, either targeting
> Release/iPhoneSimulator or Debug/iPhoneSimulator, the app
> randomly crashes when hitting the 'button' or one of the 'yes' or
> 'no' buttons on the alertview. Funny thing is that the app does
> not crash when started from the simulator. It works just fine
> then. The error only occurs when running under control of MD.
>
> This is probably a Garbage Collector error. The error happens at
> different times: sometimes only when hitting the 'yes' or 'no'
> button, sometimes even after showing the alertview, before a
> button can be pressed.
>
> Stacktrace:
>
>  at (wrapper managed-to-native)
> MonoTouch.UIKit.UIApplication.UIApplicationMain
> (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
>  at MonoTouch.UIKit.UIApplication.Main (string[],string,string)
> [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
>  at Sigsegv.Application.Main (string[]) <IL 0x00007, 0x00017>
>  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
> (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
>
> Native stacktrace:
>
>        0   Sigsegv                             0x000d1e9c
> mono_handle_native_sigsegv + 343
>        1   Sigsegv                             0x000100e0
> mono_sigsegv_signal_handler + 322
>        2   libsystem_c.dylib                   0x99b8659b _sigtramp + 43
>        3   ???                                 0xffffffff 0x0 + 4294967295
>        4   UIKit                               0x01cd84fd -[UIApplication
> sendAction:to:from:forEvent:] + 119
>        5   UIKit                               0x01d68799 -[UIControl
> sendAction:to:forEvent:] + 67
>        6   UIKit                               0x01d6ac2b
> -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
>        7   UIKit                               0x01d697d8 -[UIControl
> touchesEnded:withEvent:] + 458
>        8   UIKit                               0x01cfcded -[UIWindow
> _sendTouchesForEvent:] + 567
>        9   UIKit                               0x01cddc37 -[UIApplication
> sendEvent:] + 447
>        10  UIKit                               0x01ce2f2e
> _UIApplicationHandleEvent + 7576
>        11  GraphicsServices                    0x04053992 PurpleEventCallback + 1550
>        12  CoreFoundation                      0x00ea6944
> __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
>        13  CoreFoundation                      0x00e06cf7 __CFRunLoopDoSource1 + 215
>        14  CoreFoundation                      0x00e03f83 __CFRunLoopRun + 979
>        15  CoreFoundation                      0x00e03840 CFRunLoopRunSpecific + 208
>        16  CoreFoundation                      0x00e03761 CFRunLoopRunInMode + 97
>        17  GraphicsServices                    0x040521c4 GSEventRunModal + 217
>        18  GraphicsServices                    0x04052289 GSEventRun + 115
>        19  UIKit                               0x01ce6c93 UIApplicationMain + 1160
>        20  ???                                 0x077f6b0c 0x0 + 125790988
>        21  ???                                 0x077f5db8 0x0 + 125787576
>        22  ???                                 0x077f5c50 0x0 + 125787216
>        23  ???                                 0x077f5cdf 0x0 + 125787359
>        24  Sigsegv                             0x0000fe9b
> mono_jit_runtime_invoke + 1332
>        25  Sigsegv                             0x001ee961 mono_runtime_invoke + 137
>        26  Sigsegv                             0x001f1048 mono_runtime_exec_main + 669
>        27  Sigsegv                             0x001f0432 mono_runtime_run_main + 843
>        28  Sigsegv                             0x000a3f9e mono_jit_exec + 200
>        29  Sigsegv                             0x002a3d21 main + 3733
>        30  Sigsegv                             0x00003179 _start + 208
>        31  Sigsegv                             0x000030a8 start + 40
>
> =================================================================
> Got a SIGSEGV while executing native code. This usually indicates
> a fatal error in the mono runtime or one of the native libraries
> used by your application.
> =================================================================
>
>
> Any help or advice, any one?
>
>
> Guido.
>
(forgot to mention: running MD 2.8, Mono 2.10.5, OSX 10.7.1)


More information about the MonoTouch mailing list