Caphyon / clang-power-tools

Bringing clang-tidy magic to Visual Studio C++ developers.
http://www.clangpowertools.com
Apache License 2.0
472 stars 57 forks source link

clang-format editor crash #1278

Closed coolfrik closed 1 year ago

coolfrik commented 1 year ago

Today (12.04.2023) i update clang-power-tools to 2023.4.0 version and clang-format editor began to crash. I try reinstall clang-format editor or clang-power-tools, don't to help.

Application: ClangFormatEditor.exe
CoreCLR Version: 5.0.1722.21314
.NET Version: 5.0.17
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Collections.Generic.KeyNotFoundException: The given key 'LE_DeriveLF' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at ClangFormatEditor.DiffStyle.StyleDetector.SetOptionInput(FormatOptionInputModel inputModel, String input, FormatStyle formatStyle, List`1 formatOptions)
   at ClangFormatEditor.DiffStyle.StyleDetector.<>c__DisplayClass15_0.<DetectFileOptionsAsync>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at ClangFormatEditor.DiffStyle.StyleDetector.DetectFileOptionsAsync(String content, FormatStyle style, CancellationToken cancelToken)
   at ClangFormatEditor.DiffStyle.StyleDetector.<>c__DisplayClass12_1.<<DetectOptionsForFilesAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at ClangFormatEditor.DiffStyle.StyleDetector.DetectOptionsForFilesAsync(CancellationToken cancelToken)
   at ClangFormatEditor.DiffStyle.StyleDetector.DetectAsync(CancellationToken cancelToken)
   at ClangFormatEditor.DiffStyle.StyleDetector.DetectStyleOptionsAsync(List`1 filesContent, CancellationToken cancelToken)
   at ClangFormatEditor.MVVM.Controllers.DiffController.GetFormatOptionsAsync(List`1 filesContent, CancellationToken cancelToken)
   at ClangFormatEditor.MVVM.ViewModels.DetectorViewModel.DiffDocumentsAsync(List`1 filesPath, Window detectingWindowOwner)
   at ClangFormatEditor.MVVM.Views.DetectorView.ShowDiffAsync(List`1 filesPath, Window detectingWindowOwner)
   at ClangFormatEditor.MVVM.ViewModels.FileSelectorViewModel.DetectFormatStyleAsync()
   at ClangFormatEditor.TaskExtensions.SafeFireAndForget(Task task, Boolean continueOnCapturedContext, Action`1 onException)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__140_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at ClangFormatEditor.App.Main()
mariru27 commented 1 year ago

Hi @coolfrik ,

Thank you for reporting this issue I cannot reproduce this problem. Can you provide more details?

For example, try to install and use Clang Format Editor outside of Clang Power Tools extension (like a individual app)

In which state you get the error? Right when you open the app or when you open Format Configurator?

Best regards, Marina

coolfrik commented 1 year ago

Hi @mariru27, thanks for answer.

My steps:

  1. "Open Detector" - success;
  2. "Browse and Selected File(s)" - success;
  3. "Detect Format Style" - success;
  4. While "Detect Format Style" progress bar animate, after a couple of seconds CRASH.

I try open Clang Format Editor outside of Clang Power Tools (C:\Program Files (x86)\Caphyon\Clang Format Editor) - the same problem. I try select only one test .cpp file - the same problem.

I use windows 11 and maybe problem with .NET Framework version...

p.s. .clang-format configurator opens and works successfully :) Thanks.

mariru27 commented 1 year ago

@coolfrik, thank you so much for taking the time to give such a thorough and detailed explanation. I can reproduce the problem

We are working on a fix, I will let you know as progress are made A release with a fix may be available next week, but in the meantime you can use a previous version of Clang Format Editor

Best regards, Marina

mariru27 commented 1 year ago

In the end we managed to resolve the issue and make a release today

@coolfrik you can update now Clang Format Editor or install a new version 2023.4.1

Have a nice day, Marina

coolfrik commented 1 year ago

@mariru27 thanks for super fast fix. version 2023.4.1 works successfully!

Best regards, Alex.