Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSharpRangeToTextSpan crash on GoTo All #3180

Closed
ImaginaryDevelopment opened this issue Jun 5, 2017 · 13 comments
Closed

FSharpRangeToTextSpan crash on GoTo All #3180

ImaginaryDevelopment opened this issue Jun 5, 2017 · 13 comments
Labels
Area-LangService-API Bug Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Milestone

Comments

@ImaginaryDevelopment
Copy link

Vs 2017 is crashing on go to all after typing a few letters

Repro steps

Have not been able to reproduce outside of my enterprise solution (12 projects) 6 C#, 5 F#, 1 .SqlProj
Only started since last VS update.

Expected behavior

A list of possible matches for what I typed comes up

Actual behavior

Visual studio crashes. without showing anything in the goto all box
image

Known workarounds

use find in all files instead of the Go To All item.

Related information

Obtained by attaching VS to another instance of VS:

System.ArgumentOutOfRangeException occurred
  HResult=0x80131502
  Message=Specified argument was out of the range of valid values.
  Source=Microsoft.CodeAnalysis
  StackTrace:
   at Microsoft.CodeAnalysis.Text.TextSpan..ctor(Int32 start, Int32 length)
   at Microsoft.VisualStudio.FSharp.Editor.RoslynHelpers.FSharpRangeToTextSpan(SourceText sourceText, range range)
   at <StartupCode$FSharp-Editor>.$NavigateToSearchService.clo@198-37.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at Microsoft.FSharp.Collections.SeqModule.ToArray[T](IEnumerable`1 source)
   at <StartupCode$FSharp-Editor>.$NavigateToSearchService.clo@195-35.Invoke(FSharpParseFileResults _arg3)
   at Microsoft.FSharp.Control.AsyncBuilderImpl.args@823-1.Invoke(a a)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo.NavigateToItemProvider.Searcher.<SearchAsyncWorker>d__12.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo.NavigateToItemProvider.Searcher.<SearchAsync>d__11.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo.NavigateToItemProvider.Searcher.<Search>d__10.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_1(Object state)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
  • Windows 10
  • Visual Studio 15.2 (26439.12) Release (.NET 4.6.01586)
  • Visual F# Tools 15.4.1.17060502
    Just updated Visual F# tools to the latest nightly and it persists.
@ImaginaryDevelopment ImaginaryDevelopment changed the title FSharpRangeToTextSpan crash on GoTo Definition FSharpRangeToTextSpan crash on GoTo All Jun 5, 2017
@dsyme
Copy link
Contributor

dsyme commented Jun 5, 2017

I think the simple solution is to catch this exception in FSharpRangeToTextSpan

@cartermp
Copy link
Contributor

cartermp commented Jun 5, 2017

Or perhaps short-circuit out when StartLine is 0, as I suspect this is what's returned when FCS cannot find something that matches. Though I think it's a bit suspect that it was able to get this far and generate this kind of exception when Go to All doesn't have something to return...

@cartermp cartermp added Area-LangService-API Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. labels Jun 5, 2017
@cartermp cartermp added this to the VS 2017 Updates milestone Jun 5, 2017
@realvictorprm
Copy link
Contributor

Some additional checks in the method simply have to be made.

@dsyme
Copy link
Contributor

dsyme commented Jun 5, 2017

Or perhaps short-circuit out when StartLine is 0, as I suspect this is what's returned when FCS cannot find something that matches.

Yes

Though I think it's a bit suspect that it was able to get this far and generate this kind of exception when Go to All doesn't have something to return...

Yes :)

@dsyme
Copy link
Contributor

dsyme commented Jun 6, 2017

@ImaginaryDevelopment If possible try #3181 and see if it cures your problem? thanks

@ImaginaryDevelopment
Copy link
Author

ImaginaryDevelopment commented Jun 6, 2017 via email

@cartermp
Copy link
Contributor

cartermp commented Jun 6, 2017

@ImaginaryDevelopment Yes, it's needed to test it out.

@dsyme
Copy link
Contributor

dsyme commented Jun 6, 2017

@cartermp I'm confident that the fix is stabilizing, but it would be absolutely fantastic to try it out. Perhaps it's also needed to get the fix applied?

@ImaginaryDevelopment Alternatively you can provide us with a repro? which we can verify

thanks!
don

@ImaginaryDevelopment
Copy link
Author

ImaginaryDevelopment commented Jun 6, 2017 via email

@cartermp
Copy link
Contributor

cartermp commented Jun 6, 2017

@ImaginaryDevelopment If you're up for verifying, you can get started fairly easily. This is the workflow I use:

  1. Install prerequisites from here: https://github.com/Microsoft/visualfsharp/blob/master/DEVGUIDE.md#developing-the-visual-f-ide-tools-windows-only
  2. Open the VS Command Prompt in Administrator mode
  3. build vs
  4. msbuild VisualFSharp.sln
  5. .\VisualFSharp.sln
  6. Set VisualFSharpOpenSource as the startup project
  7. f5 or ctrl-f5 (latter will definitely be faster) to launch a hive of VS
  8. Open the project in the launched VS hive

@dsyme
Copy link
Contributor

dsyme commented Jun 12, 2017

Closing as I am convinced this is fixed. @cartermp Do we need @ImaginaryDevelopment to verify?

@dsyme dsyme closed this as completed Jun 12, 2017
@cartermp
Copy link
Contributor

It'd be great if you could verify the fix @ImaginaryDevelopment, but the code is now safe and won't crash in the manner described above so I think this is good to close.

@Thorium
Copy link
Contributor

Thorium commented Nov 17, 2023

The constant throw new ArgumentOutOfRangeException("length") -catches are interfering debugging.
Could there be added a length-check to FSharpRangeToTextSpan to RoslynHelpers.cs

return new TextSpan(num2, num - num2);

Should be rather like

var length = num - num2;
return length >= 0 ? new TextSpan(num2, length) : null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-API Bug Impact-High (Internal MS Team use only) Describes an issue with extreme impact on existing code. Regression
Projects
None yet
Development

No branches or pull requests

5 participants