Bug 8554

Summary: System.Net.NetworkInformation.Ping - SendPingAsync operation fails
Product: [Mono] Class Libraries Reporter: Stian E <stian.eikeland>
Component: SystemAssignee: Bugzilla <bugzilla>
Status: RESOLVED FIXED    
Severity: normal CC: alkpli, amccague, chesedprather, mono-bugs+mono, rupert.rawnsley
Priority: ---    
Version: unspecified   
Target Milestone: Untriaged   
Hardware: All   
OS: All   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: SendPingAsync testcase
SendPingAsync testcase

Description Stian E 2012-11-22 09:55:08 UTC
Created attachment 2998 [details]
SendPingAsync testcase

The following simple testcase works fine using .NET, but fails using Mono.

var result = new Ping().SendPingAsync(IPAddress.Loopback);
result.Wait();
Console.WriteLine(result.Result.Status);

Expected Result:
Success

Actual result:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Net.NetworkInformation.Ping.SendPingAsync (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00000] in <filename unknown>:0 
  at System.Net.NetworkInformation.Ping.SendPingAsync (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer) [0x00000] in <filename unknown>:0 
  at System.Net.NetworkInformation.Ping.SendPingAsync (System.Net.IPAddress address, Int32 timeout) [0x00000] in <filename unknown>:0 
  at System.Net.NetworkInformation.Ping.SendPingAsync (System.Net.IPAddress address) [0x00000] in <filename unknown>:0 
  at AsyncPing.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Net.NetworkInformation.Ping.SendPingAsync (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00000] in <filename unknown>:0 
  at System.Net.NetworkInformation.Ping.SendPingAsync (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer) [0x00000] in <filename unknown>:0 
  at System.Net.NetworkInformation.Ping.SendPingAsync (System.Net.IPAddress address, Int32 timeout) [0x00000] in <filename unknown>:0 
  at System.Net.NetworkInformation.Ping.SendPingAsync (System.Net.IPAddress address) [0x00000] in <filename unknown>:0 
  at AsyncPing.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

Platforms tested:
OS X (Lion) - Mono JIT compiler version 3.0.1 (master/301b6c6 Mon Nov  5 14:45:52 EST 2012)
Linux (Debian), ARM - Mono JIT compiler version 3.0.1 (tarball Sat Nov 10 00:44:18 PHT 2012)
Comment 1 Stian E 2012-11-22 10:00:43 UTC
Created attachment 2999 [details]
SendPingAsync testcase
Comment 2 chesedprather 2015-01-18 05:10:18 UTC
Still repros as of Mono Debian 3.2.8+dfsg-4ubuntu1 on LinuxMint 17.1
Comment 3 Rupert Rawnsley 2015-02-10 09:20:39 UTC
This is also a problem on Xamarin.Android Version: 4.20.0.28 (Indie Edition)
Comment 4 Adrian McCague 2016-05-11 11:36:48 UTC
I have made a pull request https://github.com/mono/mono/pull/2984 that should resolve this issue with the Task Based API operations.
Comment 5 Alexander Köplinger [MSFT] 2016-07-04 11:35:02 UTC
Adrian's pull request was merged, closing this as fixed. Thanks!