Bug 36234 - WebConnectionStream throws NullReferenceException
Summary: WebConnectionStream throws NullReferenceException
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 4.2.0 (C6)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-11-25 01:28 UTC by Jiri {x2} Cincura
Modified: 2016-03-21 15:30 UTC (History)
5 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 for Bug 36234 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:
Status:
NEW

Description Jiri {x2} Cincura 2015-11-25 01:28:31 UTC
Calling `UploadFromStreamAsync` for a blob from `WindowsAzure.Storage` ends at the end with:
Microsoft.WindowsAzure.Storage.StorageException: Object reference not set to an
instance of an object ---> System.NullReferenceException: Object reference not s
et to an instance of an object
  at System.Net.WebConnectionStream.EndRead (IAsyncResult r) [0x00007] in C:\j\w
orkspace\v\repos\mono\mcs\class\System\System.Net\WebConnectionStream.cs:402
  at Microsoft.WindowsAzure.Storage.Core.ByteCountingStream.EndRead (IAsyncResul
t asyncResult) <0x5d09060 + 0x0001a> in <filename unknown>:0
  at Microsoft.WindowsAzure.Storage.Core.Util.AsyncStreamCopier`1[T].ProcessEndR
ead () <0x5cfdad0 + 0x0002d> in <filename unknown>:0
  at Microsoft.WindowsAzure.Storage.Core.Util.AsyncStreamCopier`1[T].EndOperatio
n (IAsyncResult res) <0x5cfcf30 + 0x00053> in <filename unknown>:0
  at Microsoft.WindowsAzure.Storage.Core.Util.AsyncStreamCopier`1[T].EndOpWithCa
tch (IAsyncResult res) <0x5cfcc88 + 0x00063> in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Microsoft.WindowsAzure.Storage.Core.Util.StorageAsyncResult`1[T].End () <0x
5d0f710 + 0x0003f> in <filename unknown>:0
  at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.EndUploadFromStream (IAs
yncResult asyncResult) <0x5d0f6c8 + 0x0002f> in <filename unknown>:0
  at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions+<>c__DisplayClass4
.<CreateCallbackVoid>b__3 (IAsyncResult ar) <0x5d0f488 + 0x00095> in <filename u
nknown>:0

Works fine on MS.NET.
Comment 1 Rodrigo Kumpera 2015-11-27 17:32:22 UTC
Hi Jiri,

Could you provide a test case that shows this behavior? It will be very hard for us to figure out what's going on based just on this stack trace.
Comment 2 Jiri {x2} Cincura 2015-11-30 10:01:50 UTC
This is the simplest I can get it:
public static async Task UploadDataAsync(Stream stream, string name)
{
	stream.Position = 0;
	var blob = CreateBlobReference(name);
	var uploadOptions = new BlobRequestOptions()
	{
		ServerTimeout = TimeSpan.FromMinutes(6),
		RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(2), 3),
		DisableContentMD5Validation = false,
		StoreBlobContentMD5 = true,
		UseTransactionalMD5 = true,
	};
	uploadOptions.SingleBlobUploadThresholdInBytes = 4 * 1024 * 1024;
	uploadOptions.ParallelOperationThreadCount = 2;
	await blob.UploadFromStreamAsync(stream,
			options: uploadOptions,
			accessCondition: null,
			operationContext: null)
		.ConfigureAwait(false);
}

Fails on Windows as well as Arch Linux (on ARM).
Comment 4 Jon Goldberger [MSFT] 2016-03-04 21:45:57 UTC
It looks like support for Xamarin is in preview in the WindowsAzure.Storage package.

See: 
https://github.com/Azure/azure-storage-net#target-frameworks

"Portable Class Library Profile 111: Storage Client Libraries are available to support building PCL Profile 111 applications, as well as for Xamarin application development. This support is currently in preview."

So this may be an UPSTREAM issue?
Comment 6 Jon Goldberger [MSFT] 2016-03-04 21:50:50 UTC
It looks like this issue is already filed on the github repo:
https://github.com/Azure/azure-storage-net/issues/202
Comment 7 Mark Junker 2016-03-21 15:30:17 UTC
I guess that the problem is two-fold. The mono side problem is, that the async upload blocks (i.e. never finishes until a timeout is triggered, mono problem) which causes the NRE in the azure library (azure library problem). Using the non-async methods fixes this problem for me, because the upload doesn't get blocked any more.