Try it with Console.WriteLine (not Debug).
And/or use a ThreadPool Thread
ThreadPool.QueueUserWorkItem(delegate { Console.WriteLine("w00t!"); });
I use these everywhere.... definitely works.
Other than that, maybe raise a bug in bugzilla - sounds like something
Sebastian or Jeff need to dig into the code for :)
On Fri, Sep 16, 2011 at 20:04, Conway Wieler
<[email protected]> wrote:
> Hello,
>
> Our app runs properly when run directly on an iPod Touch, but it crashes
> when I run it in the MonoDevelop debugger. I've tracked it down to starting
> a thread by calling System.Threading.Thread.Start(). The new thread just has
> a Debug.WriteLine() in it. With the Thread.Start() call active, the app
> crashes in the debugger; with the Thread.Start() commented out, the app runs
> in the debugger. Specifically, in the AppDelegate::FinishedLaunching()
> routine, I am creating a thread and calling Start() on it:
>
>
>
> public override bool FinishedLaunching(UIApplication app, NSDictionary
> options)
>
> {
>
> initThread = new System.Threading.Thread(Initialize);
>
> initThread.IsBackground = true;
>
> initThread.Start();
>
> }
>
> private void Initialize()
>
> {
>
> Debug.WriteLine("testing");
>
> }
>
>
>
> If instead I use BeginInvokeOnMainThread(Initialize), the Initialize routine
> (the real version, not just the Debug.WriteLine() version) will run but then
> a subsequent thread create and Start() causes the same crash.
>
>
>
> The crash report (from Xcode-Organizer, below) says that the exception type
> is EXC_BAD_ACCESS / KERN_PROTECTION_FAILURE. I also get a nearly identical
> crash if I set a breakpoint on any line of C# code in the case where the
> code does run.
>
>
>
> Other possibly relevant information:
>
> 1. MonoDevelop v2.6.0.1, Mono v2.10.5, MonoTouch v4.0.7
>
> 2. I've written a HelloWorld app that similarly creates a Thread and calls
> Thread.Start() on it. It runs as expected and I see the Debug.WriteLine
> output. I can also set Breakpoints and step through code. I doubt the issue
> is with the actual thread or threading mechanism; it just seems like a
> trigger or we're reaching some threshold (perhaps memory?).
>
> 3. Our app is large. The core part of our app is a large C++ DLL, and we use
> C# for the UI and non-core support functionality. Right now the amount of C#
> code is small but growing as we continue to port our existing Windows/WinCE
> app. Are there issues with having a large application? Right now, the app is
> 29.5MB for Debug and about 14MB for Release.
>
>
>
> Has anyone seen similar behaviour? Does anyone have ideas or things to try?
>
> Thanks,
>
> Conway
>
>
>
>
>
> Crash Log:
>
> ---------------------------------------------------------------
>
> Exception Type: EXC_BAD_ACCESS (SIGSYS)
>
> Exception Codes: KERN_PROTECTION_FAILURE at 0x01cfc000
>
> Crashed Thread: 0
>
>
>
> Thread 0 name: Dispatch queue: com.apple.main-thread
>
> Thread 0 Crashed:
>
> 0 Main 0x00dd0a5c process_single_step
> (debugger-agent.c:3993)
>
> 1 ??? 0x01cfbff8 0 + 30392312
>
> 2 Main 0x008ed92c
> wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
> + 192
>
> 3 Main 0x00da9412 mono_jit_runtime_invoke
> (mini.c:5754)
>
> 4 Main 0x00e53d5a mono_runtime_invoke
> (object.c:2756)
>
> 5 Main 0x00ebfcac monotouch_trampoline
> (monotouch-glue.m:652)
>
> 6 UIKit 0x30a1781a -[UIApplication
> _callInitializationDelegatesForURL:payload:suspended:] + 766
>
> 7 UIKit 0x30a11b5e -[UIApplication
> _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 266
>
> 8 UIKit 0x309e67d0 -[UIApplication
> handleEvent:withNewEvent:] + 1108
>
> 9 UIKit 0x309e620e -[UIApplication sendEvent:]
> + 38
>
> 10 UIKit 0x309e5c4c _UIApplicationHandleEvent +
> 5084
>
> 11 GraphicsServices 0x30269e70 PurpleEventCallback + 660
>
> 12 CoreFoundation 0x30957a90
> __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
>
> 13 CoreFoundation 0x30959838 __CFRunLoopDoSource1 + 160
>
> 14 CoreFoundation 0x3095a606 __CFRunLoopRun + 514
>
> 15 CoreFoundation 0x308eaebc CFRunLoopRunSpecific + 224
>
> 16 CoreFoundation 0x308eadc4 CFRunLoopRunInMode + 52
>
> 17 UIKit 0x30a10d42 -[UIApplication _run] + 366
>
> 18 UIKit 0x30a0e800 UIApplicationMain + 664
>
> 19 Main 0x0063da8c
> wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr
> + 232
>
> 20 Main 0x0068a4c4 methods + 75556
>
> 21 Main 0x008ed92c
> wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
> + 192
>
> 22 Main 0x00da9412 mono_jit_runtime_invoke
> (mini.c:5754)
>
> 23 Main 0x00e53d5a mono_runtime_invoke
> (object.c:2756)
>
> 24 Main 0x00e55be4 mono_runtime_exec_main
> (object.c:3939)
>
> 25 Main 0x00e55214 mono_runtime_run_main
> (object.c:3561)
>
> 26 Main 0x00db0bac mono_jit_exec
> (driver.c:1102)
>
> 27 Main 0x00da2f9e main (main.m:2110)
>
> 28 Main 0x005caba0 start + 32
>
>
>
>
>
>
>
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
--
Nic Wise
t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch