Bug 5149 - NullReferenceException leads to app freezing on startup
Summary: NullReferenceException leads to app freezing on startup
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: iOS
Classification: Xamarin
Component: Debugger ()
Version: 5.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-05-17 16:22 UTC by Ray
Modified: 2012-06-04 17:11 UTC (History)
4 users (show)

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


Attachments
Stacktrace/Terminal output for the ClientRuntimeChannel bug. (15.74 KB, text/plain)
2012-05-17 16:36 UTC, Ray
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:
RESOLVED NOT_REPRODUCIBLE

Description Ray 2012-05-17 16:22:54 UTC
It's difficult to post a lot of details about this, but I posted a Stack Overflow question about it here: http://stackoverflow.com/questions/10624125/nullreferenceexception-from-clientruntimechannel-cs/10626661#comment13780202_10626661

In the ClientRuntimeChannel.Process(), I was getting an exception thrown due to a null array.Copy() call. About half of the time, the debugger would not break on the thrown exception which would lead to the app hard freezing. Sometimes it would break on the throw; line, and continuing past it would allow my app to run perfectly.

As suggested, I tried the 5.3.3 alpha (I believe I was previously on 5.2 stable?), which was said to fix this bug. This is about half correct. The exception never breaks on the throw; line anymore, but my app now freezes much more frequently than it did before. I can't even get it to run past startup anymore.

This only seems to happen in Debug. I can run a release build of the game perfectly, but debug seems to have some code enabled that's causing my app to hard freeze. (Can't even stop it in the debugger.)

I'm running the app on an iPad 2, but if there's any more information that I can supply, please let me know.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-05-17 16:27:06 UTC
If this is on the simulator, you can get a stack trace using gdb:

- At startup, take note of the PID of the process which is printed to the Application Output pad in MonoDevelop.
- Make the app hang.
- Open a terminal, and execute:

gdb program <PID>
(some output from gdb)
$ (gdb) thread apply all backtrace
(lots of stack traces)

- Then save everything in the terminal to a file and attach it to this bug report.
Comment 2 Ray 2012-05-17 16:36:42 UTC
Created attachment 1910 [details]
Stacktrace/Terminal output for the ClientRuntimeChannel bug.
Comment 3 Ray 2012-05-17 16:37:16 UTC
Thanks a lot, got that done for you! Let me know if there's anything else I can do.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-05-17 16:47:13 UTC
Looks like it's deadlocked in the GC, CC'ing runtime guys.
Comment 5 Rodrigo Kumpera 2012-05-17 17:23:44 UTC
No, it's not deadlocked on the GC. The GC thread is there happily pumping, this is why you probably mistaken for this.

The app freezes because the debugger has hit a breakpoint on the UI thread and is waiting for further instructions.

Zoltan, can you take a look on this?
Comment 6 Zoltan Varga 2012-05-17 19:03:58 UTC
The debugger thread is blocked on the GC lock:

#0  0x9724d876 in __psynch_mutexwait ()
#1  0x99f0f6af in pthread_mutex_lock ()
---Type <return> to continue, or q <return> to quit---
#2  0x001fe1dc in GC_lock () at pthread_support.c:1757
#3  0x001f5336 in GC_call_with_alloc_lock (fn=0xe16d0 <reveal_link>, 
    client_data=0xdcd7c00) at finalize.c:871
#4  0x000e1991 in mono_gc_weak_link_get (link_addr=0xdcd7c00) at boehm-gc.c:472
#5  0x0010a5db in mono_gchandle_get_target (gchandle=1) at gc.c:803
#6  0x000b1313 in get_object_allow_null [inlined] () at :1834
#7  0x000b1313 in get_object (objid=-1337939652, obj=0xb040abd4)
    at debugger-agent.c:1848

and the user thread is suspended by the debugger.
Comment 7 Ray 2012-05-18 14:02:52 UTC
Is there any kind of workarund available to continue progress on my application? This has me blocked and I cannot continue development.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2012-05-18 17:55:43 UTC
Ray, you should go back to 5.2 if 5.3.3. is blocking you. There is no known workaround yet.

That said it would probably be a lot easier to track down and fix this bug if we had a test project we can try out ourselves, would it be possible to attach that to this bug report? (you can mark attachments as private so only Xamarin employees can see them).
Comment 9 Ray 2012-05-18 18:01:51 UTC
This issue also showed up in 5.2.

Unfortunately I can't provide a test project. I'll keep tinkering with it and see if I can come up with a test case.
Comment 10 Zoltan Varga 2012-05-21 16:01:09 UTC
Enabling the 'Use SGEN..' option in Build/iPhone build/Advanced _might_ make the problem disappear.
Comment 11 Ray 2012-05-22 17:57:12 UTC
Thanks for the suggestion, but it didn't seem to make a difference.
Comment 15 Zoltan Varga 2012-05-26 05:39:57 UTC
The download worked.
Comment 18 Rolf Bjarne Kvinge [MSFT] 2012-06-01 07:33:04 UTC
Ray, I can run the app, but is there anything in particular I need to do to make it hang? It seems to work fine for me when I just click around.
Comment 19 Ray 2012-06-04 13:43:57 UTC
Frustratingly enough, I cannot seem to reproduce the error. I'll post another bug with more details and another archive the next time I run into it.
Comment 20 Rolf Bjarne Kvinge [MSFT] 2012-06-04 17:11:24 UTC
Closing this bug for now then. Please reopen if you run into it again.