Bug 42249 - Ping throws DNS not found exception
Summary: Ping throws DNS not found exception
Status: NEEDINFO
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-06-29 13:20 UTC by Jochen Kühner
Modified: 2016-11-16 12:02 UTC (History)
3 users (show)

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


Attachments

Description Jochen Kühner 2016-06-29 13:20:18 UTC
When I try to use a Ping to a IP, I get the following Exception:

System.Net.Sockets.SocketException: Could not resolve host 'GFMM01746316'
  at System.Net.Dns.Error_11001 (System.String hostName) [0x00000] in /home/build/Schreibtisch/mono-4.2.3/mcs/class/System/System.Net/Dns.cs:292 
  at System.Net.Dns.GetHostByName (System.String hostName) [0x00024] in /home/build/Schreibtisch/mono-4.2.3/mcs/class/System/System.Net/Dns.cs:419 
  at System.Net.NetworkInformation.Ping.GetNonLoopbackIP () [0x00000] in /home/build/Schreibtisch/mono-4.2.3/mcs/class/System/System.Net.NetworkInformation/Ping.cs:200 
  at System.Net.NetworkInformation.Ping.SendPrivileged (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00008] in /home/build/Schreibtisch/mono-4.2.3/mcs/class/System/System.Net.NetworkInformation/Ping.cs:226 
  at System.Net.NetworkInformation.Ping.Send (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x0005b] in /home/build/Schreibtisch/mono-4.2.3/mcs/class/System/System.Net.NetworkInformation/Ping.cs:219 
  at System.Net.NetworkInformation.Ping.Send (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer) [0x00000] in /home/build/Schreibtisch/mono-4.2.3/mcs/class/System/System.Net.NetworkInformation/Ping.cs:174 
  at System.Net.NetworkInformation.Ping.Send (System.Net.IPAddress address, Int32 timeout) [0x00000] in /home/build/Schreibtisch/mono-4.2.3/mcs/class/System/System.Net.NetworkInformation/Ping.cs:169 
  at System.Net.NetworkInformation.Ping.Send (System.Net.IPAddress address) [0x00000] in /home/build/Schreibtisch/mono-4.2.3/mcs/class/System/System.Net.NetworkInformation/Ping.cs:164 

i think
Comment 1 Jochen Kühner 2016-06-29 13:23:57 UTC
I think Problem is here: https://github.com/mono/mono/blob/master/mcs/class/System/System.Net.NetworkInformation/Ping.cs#L243

this line throws the Exception
Comment 2 João Matos 2016-07-04 18:18:24 UTC
Can you send a small example that reproduces the problem?
Comment 3 Jochen Kühner 2016-07-05 04:27:15 UTC
I simple do
new Ping(). Send(IPAddress) 
on a Yocto Linux, wich has not is own hostname in the /etc/hosts file.

It's not more Code, only this one liner.
Comment 4 Fabrizio Carimati 2016-08-09 15:43:59 UTC
I just installed latest OpenSuse on Virtualbox.
Default hostname is "linux-4e98".

# ping $HOSTNAME
fail.

Mono/Ping fail as reported by Jochen Kühner with 
Could not resolve host 'linux-4e98'.

Adding in /etc/hosts
127.0.0.1  linux-4e98
resolve the issue in Mono.

So, the GetNonLoopbackIP throw an exception if the OS hostname can't be resolved.
I ignore why Mono/Ping need to resolve the hostname.
I still think it's a Mono bug.
Comment 5 Jochen Kühner 2016-11-16 12:02:46 UTC
I've uploaded a fix at : https://github.com/mono/mono/pull/3949

Note You need to log in before you can comment on or make changes to this bug.