[mono-android] Unhandled Exception in the framework when using async sockets

Matthias m-lehmann at t-systems.com
Wed Jun 27 13:34:01 UTC 2012


Hello,

I'm using the ReceiveFromAsync() method together with SocketAsyncEventArgs
of the System.Net.Socket class to receive continuous udp packets.

Randomly i get some weird null reference exceptions that isn't coming out of
my code. The android log shows the following stuff:

06-27 13:14:41.988 I/mono-stdout( 1353): 47681.989: done.
06-27 13:14:42.016 D/dalvikvm( 1353): GC_EXPLICIT freed 59K, 50% free
2690K/5379K, external 383K/517K, paused 5ms
06-27 13:14:42.016 I/monodroid-gc( 1353): GC cleanup summary: 10 objects
tested - resurrecting 3.
06-27 13:14:46.383 E/mono    ( 1353): 
06-27 13:14:46.383 E/mono    ( 1353): Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an
object
06-27 13:14:46.383 E/mono    ( 1353):   at
System.Net.Sockets.Socket+SocketAsyncResult.Complete () [0x00000] in
<filename unknown>:0 
06-27 13:14:46.383 E/mono    ( 1353):   at
System.Net.Sockets.Socket+SocketAsyncResult.Complete (System.Exception e)
[0x00000] in <filename unknown>:0 
06-27 13:14:46.383 E/mono    ( 1353):   at
System.Net.Sockets.Socket+Worker.Accept () [0x00000] in <filename unknown>:0 
06-27 13:14:46.383 E/mono    ( 1353):   at
System.Net.Sockets.Socket+Worker.DispatcherCB
(System.Net.Sockets.SocketAsyncResult sar) [0x00000] in <filename unknown>:0 

It seems it only happens in combination with a GC run.

Some google smashing has taken me to the exactly same bug in the bug tracker
at:  https://bugzilla.xamarin.com/show_bug.cgi?id=2965
https://bugzilla.xamarin.com/show_bug.cgi?id=2965 .

I slightly changed the test code to call GC.Collect() after the
socket.Close() command and its ALWAYS crashing (tested on Droid 2 and x86
Emu).

Is there any workaround available or is possible to make a quickfix for that
issue? The stuff is pretty urgent as always .

Matthias


--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Unhandled-Exception-in-the-framework-when-using-async-sockets-tp5710605.html
Sent from the Mono for Android mailing list archive at Nabble.com.


More information about the Monodroid mailing list