Unhandled Exception in the framework when using async sockets

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Unhandled Exception in the framework when using async sockets

Matthias
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.

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
Reply | Threaded
Open this post in threaded view
|

Re: Unhandled Exception in the framework when using async sockets

Matthias
Hello,

any comment about this issue?
Want me to create an entry in the bug tracker or highlight the one for the full framework?

For me the issue is pretty important because if you want to write some shared code for Windows Phone, Android and iOS the smallest subset is usually WP and there only the async methods are exposed.

Thx for help
Matthias
Reply | Threaded
Open this post in threaded view
|

Re: Unhandled Exception in the framework when using async sockets

Jonathan Pryor-2
On Jul 10, 2012, at 4:22 AM, Matthias wrote:
> Want me to create an entry in the bug tracker or highlight the one for the full framework?

Highlight the one for the full framework.

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid