Bug 47205

Summary: Uri.TryCreate throws exception
Product: [Mono] Class Libraries Reporter: Rolf Bjarne Kvinge [MSFT] <rolf>
Component: mscorlibAssignee: Marek Safar <masafa>
Status: VERIFIED FIXED    
Severity: normal CC: masafa, mohitk, mono-bugs+mono
Priority: ---    
Version: 4.8.0 (C9)   
Target Milestone: 4.8.0 (C9)   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: test.cs

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