Bug 37475 - WebRequest has several race conditions/crashes/deadlocks
Summary: WebRequest has several race conditions/crashes/deadlocks
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2016-01-07 10:33 UTC by Alan McGovern
Modified: 2016-04-16 08:00 UTC (History)
4 users (show)

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 for Bug 37475 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Alan McGovern 2016-01-07 10:33:25 UTC
This testcase uncovers several issues:


1) 'EndGetResponse' should throw a 'WebException' if Abort has been invoked. This happens sometimes, other times we get an ObjectDisposedException.

2) Sometimes 'EndGetResponse' deadlocks.

3) Sometimes calling client.BeginGetResponse throws a SynchronizationLockException (or something) when it invokes Monitor.Exit internally. I didn't record the stacktrace, but i'll attach it when i trigger it again.

4) If you add a 'System.Threading.Thread.Sleep (1);' call right after the BeginInvoke the test starts failing because of a ConnectException on only the third iteration http://screencast.com/t/VjiD86bx . If you remove the 'Abort' then everything works as expected for all 100 iterations. Stacktrace of the exception: https://gist.github.com/alanmcgovern/9109e29d7660b7acc5f2

5) Sometimes the entire app crashes because we don't handle the abort correctly internally. I triggered that by inserting a 2ms delay between the 'BeginGetResponse' and 'Abort' calls:

6) Finally another case of the wrong exception being thrown from EndGetResponse: https://gist.github.com/alanmcgovern/26c7ca23fed6a4217365