conan-io / conan-vs-extension

Conan Extension for Visual Studio
https://marketplace.visualstudio.com/items?itemName=conan-io.conan-vs-extension
MIT License
58 stars 34 forks source link

Crash when installing package #173

Closed jlschrag closed 6 months ago

jlschrag commented 4 years ago

I was able to install the extension without incident, and I created conanfile.txt in the same directory as my .vcxproj & .sln files. Contents:

[requires]
boost/1.71.0@conan/stable

[generators]
visual_studio

[options]
*:shared=True

(I have also tried without the options section.)

If I run the "Install" command on the project, I get the crash & stack trace below. However, if I run conan install from the command line, it runs without incident. My Win32\Debug folder contains a .conan folder; though, I don't know if it was put there by the extension or by manually running the cli command.

Conan extension version 1.2.2.346 Visual Studio 2017 - version 15.9.18 (though, this particular project is still using the VS2010 compiler) Windows 10 Pro - version 1909 (build 18363.535)

Severity    Code    Description Project File    Line    Suppression State
Error       System.InvalidOperationException: Due to high risk of deadlock you cannot call GetService from a background thread in an AsyncPackage derived class. You should instead call GetServiceAsync (without calling Result or Wait on the resultant Task object) or switch to the UI thread with the JoinableTaskFactory.SwitchToMainThreadAsync method before calling GetService.
   at Microsoft.VisualStudio.Shell.AsyncPackage.GetService(Type serviceType)
   at Microsoft.VisualStudio.Shell.Package.System.IServiceProvider.GetService(Type serviceType)
   at Microsoft.VisualStudio.Shell.Package.PackageContainer.GetService(Type serviceType)
   at System.ComponentModel.Container.get_Components()
   at Microsoft.VisualStudio.Shell.Package.GetDialogPage(Type dialogPageType)
   at Conan.VisualStudio.Services.VisualStudioSettingsService.GetConanPage() in C:\projects\conan-vs-extension\Conan.VisualStudio\Services\VisualStudioSettingService.cs:line 21
   at Conan.VisualStudio.Services.VisualStudioSettingsService.GetConanInstallOnlyActiveConfiguration() in C:\projects\conan-vs-extension\Conan.VisualStudio\Services\VisualStudioSettingService.cs:line 36
   at Conan.VisualStudio.Services.VcProjectService.ExtractConanProject(IVCProject vcProject, ISettingsService settingsService) in C:\projects\conan-vs-extension\Conan.VisualStudio\Services\VcProjectService.cs:line 99
   at Conan.VisualStudio.Services.VcProjectService.<>c__DisplayClass8_0.<ExtractConanProjectAsync>b__0() in C:\projects\conan-vs-extension\Conan.VisualStudio\Services\VcProjectService.cs:line 115
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Conan.VisualStudio.Services.VcProjectService.<ExtractConanProjectAsync>d__8.MoveNext() in C:\projects\conan-vs-extension\Conan.VisualStudio\Services\VcProjectService.cs:line 113
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Conan.VisualStudio.Services.ConanService.<InstallAsync>d__7.MoveNext() in C:\projects\conan-vs-extension\Conan.VisualStudio\Services\ConanService.cs:line 92
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Conan.VisualStudio.Menu.AddConanDependsProject.<MenuItemCallbackAsync>d__6.MoveNext() in C:\projects\conan-vs-extension\Conan.VisualStudio\Menu\AddConanDependsProject.cs:line 37
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Conan.VisualStudio.Menu.MenuCommandBase.<CallMenuItemBallbackAsync>d__6.MoveNext() in C:\projects\conan-vs-extension\Conan.VisualStudio\Menu\MenuCommandBase.cs:line 31           0   
jlschrag commented 4 years ago

Update: After upgrading this project to the VS2017 compiler, the issue disappears. The extension does say it supports only VS2017, but it is worth noting that VS2017 will run projects targeting older compilers without updating them. So, it may be worth adding a note about compiler support somewhere.

jgsogo commented 4 years ago

Hi, @jlschrag . The extension should work for any version from VS 2015 (latest ones) to 2019, but it's true that I've only tested it without changing the matching compiler for each version (there are too many combinations). Probably there is an error when the extension creates the profile to use with Conan to download/build the requirements, but the stack trace is not useful at all 😞

We'll try to reproduce the error, but also to improve those logs/stack traces,...