Bug 47205 - Uri.TryCreate throws exception
Summary: Uri.TryCreate throws exception
Status: VERIFIED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: 4.8.0 (C9)
Hardware: PC Mac OS
: --- normal
Target Milestone: 4.8.0 (C9)
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-11-17 17:26 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2016-11-18 18:40 UTC (History)
3 users (show)

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


Attachments
test.cs (239 bytes, text/plain)
2016-11-17 17:26 UTC, Rolf Bjarne Kvinge [MSFT]
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:
VERIFIED FIXED

Description Rolf Bjarne Kvinge [MSFT] 2016-11-17 17:26:53 UTC
Created attachment 18511 [details]
test.cs

Compile & run attached sample code.

Result:

$ mcs test.cs && mono test.exe

Unhandled Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at System.Uri.CreateUriInfo (System.Uri+Flags cF) [0x0005e] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.EnsureUriInfo () [0x0001b] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.ParseRemaining () [0x00000] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.EnsureParseRemaining () [0x00014] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.InitializeUri (System.ParsingError err, System.UriKind uriKind, System.UriFormatException& e) [0x00247] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.CreateHelper (System.String uriString, System.Boolean dontEscape, System.UriKind uriKind, System.UriFormatException& e) [0x00086] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.TryCreate (System.String uriString, System.UriKind uriKind, System.Uri& result) [0x0000d] in <572a05facea34758b2998862480c99bd>:0 
  at C.Main () [0x00000] in <6dc55f07d0b04e6daf1fb6d0f6a588ac>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IndexOutOfRangeException: Index was outside the bounds of the array.
  at System.Uri.CreateUriInfo (System.Uri+Flags cF) [0x0005e] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.EnsureUriInfo () [0x0001b] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.ParseRemaining () [0x00000] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.EnsureParseRemaining () [0x00014] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.InitializeUri (System.ParsingError err, System.UriKind uriKind, System.UriFormatException& e) [0x00247] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.CreateHelper (System.String uriString, System.Boolean dontEscape, System.UriKind uriKind, System.UriFormatException& e) [0x00086] in <572a05facea34758b2998862480c99bd>:0 
  at System.Uri.TryCreate (System.String uriString, System.UriKind uriKind, System.Uri& result) [0x0000d] in <572a05facea34758b2998862480c99bd>:0 
  at C.Main () [0x00000] in <6dc55f07d0b04e6daf1fb6d0f6a588ac>:0 

Expected result: no exceptions.

This bug causes XS to crash for me.

$ mono --version
Mono JIT compiler version 4.8.0 (mono-4.8.0-branch/4c51a5c Wed Nov 16 23:34:14 EST 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:          yes(3.6.0svn-mono-master/8b1520c)
	GC:            sgen
Comment 1 Marek Safar 2016-11-18 17:32:34 UTC
Fixed in master and Mono 4.8 branch
Comment 2 Mohit Kheterpal 2016-11-18 18:40:01 UTC
Able to reproduce this issue with Mono : MonoFramework-MDK-4.8.0.361.macos10.xamarin.universal_c14675323cab114b71127f74fa1430472e55a5d8

and observed that this issue has been fixed with Mono : MonoFramework-MDK-4.8.0.362.macos10.xamarin.universal_87f3182f8f0bc222a3c2c8040b8171038c3eaa79

as shown in screencast : http://www.screencast.com/t/EdaVQcOS

Hence closing this issue by marking it as Verified.

thanks