Bug 12349 - HttpClient.GetStringAsync throws NullReferenceException on concurrent requests.
Summary: HttpClient.GetStringAsync throws NullReferenceException on concurrent requests.
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-05-22 13:35 UTC by Håvard Sørbø
Modified: 2013-05-28 05:14 UTC (History)
2 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 FIXED

Description Håvard Sørbø 2013-05-22 13:35:05 UTC
In mono 3.0.6-mac-x64 and 3.0.10-linux-amd64 running several GetStringAsync concurrently on one HttpClient-object causes NullReferenceException.

Sample

 private static void Main(string[] args)
        {
            var c = new HttpClient();
            var requests = from _ in Enumerable.Range(0, 2) select (Task) c.GetStringAsync("http://www.google.com");
            Task.WaitAll(requests.ToArray());
        }


mono 3.0.10 linux

Unhandled Exception:
System.AggregateException: One or more errors occured ---> System.NullReferenceException: Object reference not set to an instance of an object
  at System.Net.Http.HttpClient+<SendAsyncWorker>c__async5.MoveNext () [0x00200] in /buildlocal/mono-develop-multiarch/ARCH/amd64/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:292
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /buildlocal/mono-develop-multiarch/ARCH/amd64/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <filename unknown>:0
  at System.Net.Http.HttpClient+<GetStringAsync>c__asyncA.MoveNext () [0x00027] in /buildlocal/mono-develop-multiarch/ARCH/amd64/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:329
  --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken) [0x00139] in /buildlocal/mono-develop-multiarch/ARCH/amd64/mcs/class/corlib/System.Threading.Tasks/Task.cs:736
  at System.Threading.Tasks.Task.WaitAll (System.Threading.Tasks.Task[] tasks) [0x00000] in /buildlocal/mono-develop-multiarch/ARCH/amd64/mcs/class/corlib/System.Threading.Tasks/Task.cs:677
  at TestHttpClient.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
 --> (Inner exception 0) System.NullReferenceException: Object reference not set to an instance of an object
  at System.Net.Http.HttpClient+<SendAsyncWorker>c__async5.MoveNext () [0x00200] in /buildlocal/mono-develop-multiarch/ARCH/amd64/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:292
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /buildlocal/mono-develop-multiarch/ARCH/amd64/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <filename unknown>:0
  at System.Net.Http.HttpClient+<GetStringAsync>c__asyncA.MoveNext () [0x00027] in /buildlocal/mono-develop-multiarch/ARCH/amd64/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:329


mono --version
Mono JIT compiler version 3.0.10 ((no/eff4cb5 Tue Apr 30 22:15:34 UTC 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug
	LLVM:          supported, not enabled.
	GC:            Included Boehm (with typed GC and Parallel Mark)

Linux foo 2.6.32-5-xen-amd64 #1 SMP Sun Sep 23 13:49:30 UTC 2012 x86_64 GNU/Linux
Comment 1 Marek Safar 2013-05-28 05:14:58 UTC
Fixed in master