Bug 8531 - Udp Socket SendToAsync fails and crashes
Summary: Udp Socket SendToAsync fails and crashes
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-11-20 16:39 UTC by Pavlos Touboulidis
Modified: 2013-01-11 11:00 UTC (History)
2 users (show)

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


Attachments
Testcase (6.98 KB, text/x-csharp)
2012-11-20 16:39 UTC, Pavlos Touboulidis
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 GitHub or Developer Community 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 FIXED

Description Pavlos Touboulidis 2012-11-20 16:39:00 UTC
Created attachment 2979 [details]
Testcase

The attached testcase demonstrates a Udp socket that "clients" subscribe to (by sending a simple message to it) and receive heartbeats every second.
The testcase works fine on .NET, fine with BeginSendTo() but fails and crashes if SendToAsync() is used and there are two (or more) subscribed "clients".

Compile with:
dmcs -define:USE_ASYNC udptest.cs
to use the xxxAsync methods and see the problem, or remote the -define to use the Beginxxx methods.

Actual output:
--------------
$ mono --debug udptest.exe
You should see two 'Send' per second, followed by two 'Got 13 bytes' messages.

Press enter to crash

Read
Read
SendSend
Got 13 bytes
Got 13 bytes
SendSend
Got 13 bytes
SendSend
SendSend
SendSend
SendSend
<Enter pressed>

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Net.Sockets.Socket+SocketAsyncResult.Complete () [0x00000] in /build/src/mono-2.10.8/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:240 
  at System.Net.Sockets.Socket+SocketAsyncResult.Complete (System.Exception e) [0x00007] in /build/src/mono-2.10.8/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:304 
  at System.Net.Sockets.Socket+Worker.Accept () [0x00077] in /build/src/mono-2.10.8/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:510 
  at System.Net.Sockets.Socket+Worker.DispatcherCB (System.Net.Sockets.SocketAsyncResult sar) [0x0009e] in /build/src/mono-2.10.8/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:432 
--------------

Expected output (observed when using the Beginxxx methods):
--------------
$ mono --debug udptest.exe
You should see two 'Send' per second, followed by two 'Got 13 bytes' messages.

Read
Read
SendSend
Got 13 bytes
Got 13 bytes
SendSend
Got 13 bytes
Got 13 bytes
SendSend
Got 13 bytes
Got 13 bytes
SendSend
Got 13 bytes
Got 13 bytes
SendSend
Got 13 bytes
Got 13 bytes
SendSend
Got 13 bytes
Got 13 bytes
^C
--------------
Comment 1 Rodrigo Kumpera 2013-01-11 11:00:27 UTC
Work with mono 3.0.3.