Bug 12274 - System.Net.Dns.BeginGetHostAddresses throws unhandled SocketException if networking is disabled
Summary: System.Net.Dns.BeginGetHostAddresses throws unhandled SocketException if netw...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2013-05-16 23:04 UTC by Matt Greer
Modified: 2016-11-11 09:43 UTC (History)
2 users (show)

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


Attachments
Small repro of the issue (469 bytes, text/plain)
2013-05-16 23:05 UTC, Matt Greer
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 Matt Greer 2013-05-16 23:04:39 UTC
With networking disabled, System.Net.Dns.BeginGetHostAddress() throws a SocketException with the error "no host found". This exception is unhandled and thrown in a background thread, causing the application to crash with no hope of catching the exception since it's in a thread beyond the developer's control.

Repro:
1) Take the attached example and compile it in MonoDevelop on Linux
2) Run the application with access to the internet (networking is enabled)

expect: no issues, application completes normally
actual: as expected

3) turn off networking (for me, on Ubuntu 12, I unselected "Enable Wireless" from the wifi menu.
4) Run the app again

expected: no issues, application fails to look up the DNS entry for the provided name but does not crash
actual: crashes with an unhandled SocketException.


my environment:
==================
OS: Ubuntu 12.04.2 LTS "Precise", 32 bit
Mono: Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2) 
Hardware: 7 year old MacBook with an Intel processor
Comment 1 Matt Greer 2013-05-16 23:05:19 UTC
Created attachment 3979 [details]
Small repro of the issue
Comment 2 Matt Greer 2013-05-16 23:06:26 UTC
This is Linux specific. At the very least, this does not happen on OSX Mountain Lion with Mono 2.10.12
Comment 3 Martin Baulig 2016-11-11 09:43:18 UTC
Closing ancient bugs, please reopen if you're still having this problem.