Bug 22322 - xbuild - Unhandled Exception: while building an iOS project (should fail gracefully)
Summary: xbuild - Unhandled Exception: while building an iOS project (should fail grac...
Status: NEW
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-08-23 13:29 UTC by Sebastien Pouliot
Modified: 2015-03-09 14:38 UTC (History)
1 user (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 22322 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 Sebastien Pouliot 2014-08-23 13:29:21 UTC
If you checkout 687dfbaef59348261e76592ad5a1e52adf6002b1 of monotouch/ios8-7.4.0

note: I suspect the output below is enough

$ cd /Developer/MonoTouch/Source/monotouch/tests/monotouch-test
$ xbuild monotouch-test-dual.csproj 

		Process exited with code 1, command:
		/Applications/Xcode6-Beta6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang  -gdwarf-2 -std=c99 -I/Developer/MonoTouch/Source/monotouch/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/SDKs/MonoTouch.iphonesimulator.sdk/usr/include -isysroot /Applications/Xcode6-Beta6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -Qunused-arguments -fobjc-legacy-dispatch -fobjc-abi-version=2 -mios-simulator-version-min=4.2 -arch x86_64 -c -DDEBUG  -o /Developer/MonoTouch/Source/monotouch/tests/monotouch-test/obj/iPhoneSimulator/DebugX/mtouch-cache/registrar.x86_64.o -Wno-receiver-forward-class -x objective-c /Developer/MonoTouch/Source/monotouch/tests/monotouch-test/obj/iPhoneSimulator/DebugX/mtouch-cache/64/registrar.m
		In file included from /Developer/MonoTouch/Source/monotouch/tests/monotouch-test/obj/iPhoneSimulator/DebugX/mtouch-cache/64/registrar.m:40:
		/Applications/Xcode6-Beta6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.h:8:2: error: Metal Simulator is currently unsupported
		#error Metal Simulator is currently unsupported

Unhandled Exception:
System.ArgumentOutOfRangeException: startIndex > this.length
Parameter name: startIndex
  at System.String.IndexOf (Char value, Int32 startIndex) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.MSBuildErrorParser.TryParseLine (System.String line) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.ToolTask.LogEventsFromTextOutput (System.String singleLine, MessageImportance importance) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.ToolTask.ProcessLine (System.Text.StringBuilder outputBuilder, System.String line, MessageImportance importance) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.ToolTask+<ExecuteTool>c__AnonStorey0.<>m__1 (System.Object _, System.String msg) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.ProcessWrapper.CaptureError () [0x00000] in <filename unknown>:0 
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: startIndex > this.length
Parameter name: startIndex
  at System.String.IndexOf (Char value, Int32 startIndex) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.MSBuildErrorParser.TryParseLine (System.String line) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.ToolTask.LogEventsFromTextOutput (System.String singleLine, MessageImportance importance) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.ToolTask.ProcessLine (System.Text.StringBuilder outputBuilder, System.String line, MessageImportance importance) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.ToolTask+<ExecuteTool>c__AnonStorey0.<>m__1 (System.Object _, System.String msg) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Utilities.ProcessWrapper.CaptureError () [0x00000] in <filename unknown>:0 
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0 


Version:
Mono JIT compiler version 3.6.0 ((no/f540f8a Tue Jul 15 19:37:27 EDT 2014)
Comment 1 Jeffrey Stedfast 2014-08-25 18:02:40 UTC
I think this is the exception that is causing the connection with the MSBuild host to fail.

I got this exception at around the same time I got an error trying to build one of Rustam's projects when I got the connection refused build error.
Comment 2 Sebastien Pouliot 2014-08-25 18:05:43 UTC
It could be "one" of them - but this is not the one I had in my "transport error" that resulted in a "connection failure".
Comment 3 Jeffrey Stedfast 2014-08-25 18:24:59 UTC
I guess that means there might be a few (either that or I had another exception that cuased it and it just so happened this was also in my console spew)
Comment 4 Jeffrey Stedfast 2014-08-25 18:33:19 UTC
I suspect this is the broken code snippet (but I don't know for sure):

int originEnd = line[originStart] == ':'? originStart : line.IndexOf (':', originStart + 2) - 1;

There's no check to make sure that line.Length > originStart + 2

I'm not sure what the proper fix is, though...


Assigning to mhutch since he wrote this code.
Comment 5 Jeffrey Stedfast 2014-08-27 18:29:59 UTC
Fixed this by not allowing the ToolTasks to fall back to using the default output parser...

xbuild should probably still fix this issue, tho.
Comment 6 Mikayla Hutchinson [MSFT] 2014-08-27 19:45:22 UTC
Yes, we should have a try/catch in the output read callbacks and fix the exception in the parser.