Hi all,

I have come across with the following bug on Mono v1.1.7 run under Linux: when I use asyncronous DNS resolution and domain name is not found, then I get normal exception, however after that a new exception is thrown from inside of core library and it falls into global unhandled exceptions handler -- its as if this known exception is not suppressed in the callback, which it is. I have attached C# sample that I used to reproduce this error. Here are text outputs from different OSes:

Under Linux:

------------------------------------------------------------------------------------------------
About to start resolving fv7ov41hycwpjyec3p.cywater.com

AsyncDNSResolved() exception: System.Net.Sockets.SocketException: No such host is known
in <0x0009f> System.Net.Dns:GetHostByName (System.String hostName)
in <0x00066> System.Net.Dns:Resolve (System.String hostName)
in (wrapper delegate-invoke) System.MulticastDelegate:invoke_IPHostEntry_string (string)

BUG -- UNHANDLED EXCEPTION: System.Net.Sockets.SocketException: No such host is known
in <0x0009f> System.Net.Dns:GetHostByName (System.String hostName)
in <0x00066> System.Net.Dns:Resolve (System.String hostName)
in (wrapper delegate-invoke) System.MulticastDelegate:invoke_IPHostEntry_string (string)
------------------------------------------------------------------------------------------------

Note that second exception is exactly the same as the first -- it is caught by unhandled exceptions handler.

here is what I get under windows using both Mono and native .NET 1.1:

----------------------------------------------------------------------------
About to start resolving fv7ov41hycwpjyec3p.cywater.com

AsyncDNSResolved() exception: System.Net.Sockets.SocketException: The requested name is valid and was found in the database, but it does not have the correct as
sociated data being resolved for

Server stack trace:
  at System.Net.Dns.GetHostByName(String hostName)
  at System.Net.Dns.Resolve(String hostName)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(MethodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInC ontext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMe
ssage msg, IMessageSink replySink)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg,Boolean bProxyCase) at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
  at System.Net.ResolveDelegate.EndInvoke(IAsyncResult result)
  at System.Net.Dns.EndResolve(IAsyncResult asyncResult)
at Majestic12.MonoDnsBug.AsyncDNSResolved(IAsyncResult oAR) in h:\alex\projects\tests\monodnsbug\monodnsbug.cs:line 59
----------------------------------------------------------------------------

As you can see there is no additional exception that has to be caught by the UNHANDLED exception handler.

I think this is because exception handled by the asyncronoous call back routine is rethrown again by the library.

Any comments would be appreciated.

Alex


using System;
using System.Net;

namespace Majestic12
{
        /// <summary>
        /// Mono Dns Resolve bug test: an unhandled exception is triggered 
        /// when DNS name could not be resolved (using async DNS resolutions)
        /// </summary>
        class MonoDnsBug
        {

                public void GlobalExceptionHandler(object sender, 
UnhandledExceptionEventArgs args)
                {
                        Exception oEx=(Exception) args.ExceptionObject;

                        Console.WriteLine("BUG -- UNHANDLED EXCEPTION: 
"+oEx.ToString());
                }

                [STAThread]
                static void Main(string[] args)
                {
                        MonoDnsBug oM=new MonoDnsBug();
                        oM.Start();

                        Console.ReadLine();
                }

                public void Start()
                {
                        AppDomain oCurDomain = AppDomain.CurrentDomain;
                        oCurDomain.UnhandledException+=new 
UnhandledExceptionEventHandler(GlobalExceptionHandler);

                        // this domain name is non-existant 
                        ResolveDNS("fv7ov41hycwpjyec3p.cywater.com");
                }


                private void ResolveDNS(string sDomainName)
                {
                        try
                        {
                                Console.WriteLine("About to start resolving 
{0}",sDomainName);
                                Dns.BeginResolve(sDomainName,new 
AsyncCallback(AsyncDNSResolved),null);
                        }
                        catch(Exception oEx)
                        {
                                Console.WriteLine("ResolveDNS() exception: 
"+oEx.ToString());
                        }

                }

                // callback we get from DNS resolver
                private void AsyncDNSResolved(IAsyncResult oAR)
                {

                        try
                        {
                                IPHostEntry oIP=Dns.EndResolve(oAR);

                                Console.WriteLine("Domain name was successfully 
resolved!");
                        }
                        catch(Exception oEx)
                        {
                                Console.WriteLine("AsyncDNSResolved() 
exception: "+oEx.ToString());
                        }
                }

        }
}
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to