MBulli / SmartCommandlineArgs

A Visual Studio Extension which aims to provide a better UI to manage your command line arguments
GNU General Public License v2.0
98 stars 35 forks source link

Crash on load, OOM exception #100

Closed redklyde closed 1 year ago

redklyde commented 4 years ago

I have a rather large solution with many projects and configurations. VS 2015 Update 3, with latest CLArgs, 2.2 I believe.

If I disable CLArgs, I can open the solution just fine, but with it enabled it will crash with an OOM exception. At one point I was able to open the solution with CLArgs enabled, but the window was hidden. When I opened the window, it froze for a long time and I watched memory slowly creep up. I didn't wait for it to crash, but after a while I just closed it.

For a while it would just hard restart with no error messages, but finally VS generated a report

VsProjectFault_43bf9f0a-586e-4d79-be25-d5fa8760a3af.failure.txt

abhishekp314 commented 4 years ago

I am experiencing the same issue.

abhishekp314 commented 4 years ago

After debugging a bit, I figured that one of my project directory exceeds 260 characters which causes an exception in the GetDirectoryName().

I tried to quickly build with this in app.config (reference MSDN)

<runtime>   
   <AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false" />   
</runtime> 

But I had same problem. Another solution would be to target the extension to .NET framework 4.6.2 or above, in which case by default extension can support long path names. I will have a look at it when I have time next week.

MBulli commented 4 years ago

@abhishekp314 Nice finding! We would never be able to reproduce that. I don't know if there are compatibly issues when retargeting the extension to a higher .Net version.

abhishekp314 commented 4 years ago

@MBulli I managed to fix it today. So there is more than just updating the SmartArgs project to .Net 4.6.2.

It seems that the exception occurs within the package Microsoft.VisualStudio.ProjectSystem. Following is the callstack,

SetSite failed for package [CmdArgsPackage]Source: 'Microsoft.VisualStudio.ProjectSystem.Implementation' Description: The expression "[System.IO.Path]::GetDirectoryName()" cannot be evaluated. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets System.Exception: The expression "[System.IO.Path]::GetDirectoryName()" cannot be evaluated. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets at System.Dynamic.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, UInt32 argErr, String message) at CallSite.Target(Closure , CallSite , ComObject ) at CallSite.Target(Closure , CallSite , Object ) at SmartCmdArgs.Helper.ProjectArguments.GetVCProjEngineAllArguments(Project project, List1 allArgs) in F:\GitProjects\SmartCommandlineArgs\SmartCmdArgs\SmartCmdArgs\Helper\ProjectArguments.cs:line 127 at SmartCmdArgs.Helper.ProjectArguments.<>c.<.cctor>b__13_5(Project project, List1 allArgs) in F:\GitProjects\SmartCommandlineArgs\SmartCmdArgs\SmartCmdArgs\Helper\ProjectArguments.cs:line 189 at SmartCmdArgs.Helper.ProjectArguments.AddAllArguments(IVsHierarchy project, List`1 allArgs) in F:\GitProjects\SmartCommandlineArgs\SmartCmdArgs\SmartCmdArgs\Helper\ProjectArguments.cs:line 241 at SmartCmdArgs.CmdArgsPackage.ReadCommandlineArgumentsFromProject(IVsHierarchy project) in F:\GitProjects\SmartCommandlineArgs\SmartCmdArgs\SmartCmdArgs\CmdArgsPackage.cs:line 619 at SmartCmdArgs.CmdArgsPackage.UpdateCommandsForProject(IVsHierarchy project) in F:\GitProjects\SmartCommandlineArgs\SmartCmdArgs\SmartCmdArgs\CmdArgsPackage.cs:line 478 at SmartCmdArgs.CmdArgsPackage.InitializeForSolution() in F:\GitProjects\SmartCommandlineArgs\SmartCmdArgs\SmartCmdArgs\CmdArgsPackage.cs:line 495 at SmartCmdArgs.CmdArgsPackage.d28.MoveNext() in F:\GitProjects\SmartCommandlineArgs\SmartCmdArgs\SmartCmdArgs\CmdArgsPackage.cs:line 164 --- 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 Microsoft.VisualStudio.Shell.AsyncPackage.<>cDisplayClass16_0.<b1>d.MoveNext() --- 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 Microsoft.VisualStudio.Threading.JoinableTask.d78.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.Services.VsTask.RethrowException(AggregateException e) at Microsoft.VisualStudio.Services.VsTask.InternalGetResult(Boolean ignoreUIThreadCheck) at Microsoft.VisualStudio.Services.VsTask.GetResult()

Indeed this package Microsoft.VisualStudio.ProjectSystem is quite outdated. So updating this package to 15.8.243 fixes the issue because it's targeted above .net 4.6.2.

I don't have enough understanding of these packages and hierarchy so I am not sure if this is the right way to do it. You might have better understanding of it.

Here is the fix that I did LongPathCrashFix

Thanks

Irame commented 1 year ago

This should be fixed with version 2.4 and later. If I'm mistaken please let me know, thanks.