PistonDevelopers / VisualRust

Visual Studio extension for Rust
MIT License
701 stars 73 forks source link

Visual rust crashes msbuild while building in VS 2017 #296

Closed orvly closed 6 years ago

orvly commented 6 years ago

1) Downloaded latest VS 2017 related build from Appveyor, from here: https://ci.appveyor.com/project/vosen/visualrust/build/artifacts (built from master, f005c247)

2) Installed it on Visual Studio 2017 Community. It is a clean installation (installed it just yesterday) , and the only Visual Studio installed on my OS.

3) I have both stable and beta rust installed, both of them build the project from step (4) correctly. The default one is beta (but I also tried changing the default to stable and it happened).

4) Opened a toml file for a small project which it opened correctly. 5) When pressing build project, msbuild.exe crashed. 6) Attaching to it from another instance of VS 2017, I saw the following exception:

Exception

System.NullReferenceException.

Local variables in the crash point

(LogRustcMessage method, see stack trace below), as seen in the attached VS 2017 "locals" window:

  msg          null                                                  VisualRust.Shared.Message.RustcMessageJson
  rootPath    "C:\\Users\\orvly\\rust\\blogposts"       string
  log         {Microsoft.Build.Utilities.TaskLoggingHelper}   Microsoft.Build.Utilities.TaskLoggingHelper

I looked at the source code for ExecuteCargo, and tried looking at the locals in the anonymous closure from ExecuteCargo but they were optimized and VS 2017 won't let me see them. My dotnet debugging foo isn't that strong :-) So I can't tell you why the message is null.

Stack trace :

VisualRust.Build.dll!VisualRust.Build.Rustc.LogRustcMessage(VisualRust.Shared.Message.RustcMessageJson msg, string rootPath, Microsoft.Build.Utilities.TaskLoggingHelper log) Unknown VisualRust.Build.dll!VisualRust.Build.CargoBuild.ExecuteCargo.AnonymousMethod__4_1(object sender, System.Diagnostics.DataReceivedEventArgs e) Unknown System.dll!System.Diagnostics.Process.OutputReadNotifyUser(string data) Unknown System.dll!System.Diagnostics.AsyncStreamReader.FlushMessageQueue() Unknown System.dll!System.Diagnostics.AsyncStreamReader.GetLinesFromStringBuilder() Unknown System.dll!System.Diagnostics.AsyncStreamReader.ReadBuffer(System.IAsyncResult ar) Unknown mscorlib.dll!System.IO.Stream.ReadWriteTask.InvokeAsyncCallback(object completedTask) Unknown mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown mscorlib.dll!System.IO.Stream.ReadWriteTask.System.Threading.Tasks.ITaskCompletionAction.Invoke(System.Threading.Tasks.Task completingTask) Unknown mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Unknown mscorlib.dll!System.Threading.Tasks.Task.FinishStageThree() Unknown mscorlib.dll!System.Threading.Tasks.Task.FinishStageTwo() Unknown mscorlib.dll!System.Threading.Tasks.Task.Finish(bool bUserDelegateExecuted) Unknown mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot) Unknown mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution) Unknown mscorlib.dll!System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() Unknown

MaulingMonkey commented 6 years ago

This looks like the same crash that I've fixed in https://github.com/PistonDevelopers/VisualRust/pull/286/commits/6323a84b3f329a131dabac36547acdc0315913f1 - that pull request hasn't been reviewed yet unfortunately.

If you're feeling particularly brave, I've got appveyor running against my (hopefully temporary) fork too. Not only has nobody from the project has reviewed my changes - I haven't even tested the appveyor produced binaries - only my own locally built VS2015 ones! But hey, they might work?

https://ci.appveyor.com/project/MaulingMonkey/visualrust/build/job/bgfigmcko2211nin/artifacts

If you do want to try it out, you'll want to uninstall the previous version (twice! via Visual Studio's "Extensions and Updates", and then via Windows's "Programs and Features") before installing mine.

orvly commented 6 years ago

Thanks, that did it, it works perfectly now in VS2017! Including compiling, running and debugging.

I'll close this issue I guess, even though this isn't yet part of the official build. But then again neither is the VS2017 build I downloaded in the first place.

There was one more problem though - all the files in the project initially appeared, but then disappeared after saving the sln file which VS generated for me. I had to enable "Show All Files" in the solution in order to see them. I'm not sure if that's a bug or a feature though, and I haven't read through the other issues to see if that's a known one. Also, racer doesn't quite work for autocomplete - it always gives me the same generic completions regardless of context. But again I'm not sure if it's supposed to work or not since this build doesn't seem to be official and all... I'll try to dig into it later if I'll have time.

MaulingMonkey commented 6 years ago

There was one more problem though - all the files in the project initially appeared, but then disappeared after saving the sln file which VS generated for me. I had to enable "Show All Files" in the solution in order to see them. I'm not sure if that's a bug or a feature though, and I haven't read through the other issues to see if that's a known one.

That's a bug. One I haven't encountered so far - my Cargo.lock/toml shows up fine, as do my files in src/. It's only if I want to see target/ as well, that I need to enable Show All Files. Might see if the "Visual Rust" dropdown category in your Output tab shows anything interesting, since some of the project stuff is logged to there.

Also, racer doesn't quite work for autocomplete - it always gives me the same generic completions regardless of context. But again I'm not sure if it's supposed to work or not since this build doesn't seem to be official and all... I'll try to dig into it later if I'll have time.

I've been working to improve intellisense results in that branch, but I've been using a cargo rustup-supplied racer instead of the Visual Rust bundled one, even since before I began my work IIRC. The bundled racer might just be in need of an update? Keywords will generally always show up in all contexts, even where they don't make sense, as well.

jnm2 commented 6 years ago

The link (https://ci.appveyor.com/project/MaulingMonkey/visualrust/build/job/bgfigmcko2211nin/artifacts) doesn't have any artifacts. Should I just use the latest succeeding build?