Bug 41876 - Mono 4.4 loses ability to send web requests to IP addresses
Summary: Mono 4.4 loses ability to send web requests to IP addresses
Status: RESOLVED DUPLICATE of bug 41782
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.5.X
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-06-16 02:22 UTC by Jim Borden
Modified: 2016-06-16 19:18 UTC (History)
4 users (show)

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

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 DUPLICATE of bug 41782

Description Jim Borden 2016-06-16 02:22:10 UTC
Possibly related to #41782 and affects 4.4, but not 4.2.3.4 (release on homebrew).  When I try to get a response from a server using its IP address (unless it is localhost, which seems to take a special code path), GetHostByAddr_internal appears to hang.  Eventually the request will simply time out without ever getting sent over the wire.  Here is a small repro case that works on 4.2.3.4 but fails on 4.4:

> var request = WebRequest.CreateHttp("http://74.125.206.105"); //www.google.com
> request.Timeout = 10000;
> request.Method = "HEAD";
> try
> {
>     var response = (HttpWebResponse)request.GetResponse();
>     Console.WriteLine($"Got response {response.StatusCode}");
> }
> catch (Exception e)
> {
>     Console.WriteLine("ERROR {0}", e);
> }

> Console.ReadKey(true);

Output on 4.2.3.4:
Got response OK

Output on 4.4:
ERROR System.Net.WebException: The request timed out
  at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00046] in /private/tmp/source-mono-4.4.0-c7-baseline/bockbuild-mono-4.4.0-c7-baseline/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Net/HttpWebRequest.cs:1001 
  at System.Net.HttpWebRequest.GetResponse () [0x0000e] in /private/tmp/source-mono-4.4.0-c7-baseline/bockbuild-mono-4.4.0-c7-baseline/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/System/System.Net/HttpWebRequest.cs:1019 
  at WTFWebRequest.MainClass.Main (System.String[] args) [0x00024] in /Users/borrrden/Projects/WTFWebRequest/Program.cs:35 

Pausing in the debugger shows 4.4 stuck on this line:
> bool ret = GetHostByAddr_internal(address, out h_name, out h_aliases, out h_addrlist);

Two other threads are on the same line in WaitHandle.WaitOne():
> return (WaitOne_internal(safe_wait_handle.DangerousGetHandle (), millisecondsTimeout, exitContext));

One comes from blocking on GetResponse, and the other comes from a timer somewhere.
Comment 1 Jim Borden 2016-06-16 02:38:57 UTC
I changed the affected version because I just compiled and tried 4.5.1:

Mono JIT compiler version 4.5.1 (mono-4.5.1-branch/8a2fd1e Thu Jun 16 11:21:48 JST 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  x86
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen


With the same result
Comment 2 Marek Safar 2016-06-16 19:18:43 UTC

*** This bug has been marked as a duplicate of bug 41782 ***