microsoft / perfview

PerfView is a CPU and memory performance-analysis tool
http://channel9.msdn.com/Series/PerfView-Tutorial
MIT License
4.13k stars 706 forks source link

Exception when rendering flame graph #825

Open grisharav opened 5 years ago

grisharav commented 5 years ago

StackTrace: System.ArgumentException: Width and Height must be non-negative. at System.Windows.Rect..ctor(Double x, Double y, Double width, Double height) at PerfView.FlameGraphDrawingCanvas.Draw(IEnumerable`1 boxes) at PerfView.StackWindow.RedrawFlameGraph() at PerfView.StackWindow.RedrawFlameGraphIfVisible() at PerfView.StackWindow.FlameGraphCanvas_SizeChanged(Object sender, SizeChangedEventArgs e) at System.Windows.SizeChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.FrameworkElement.OnRenderSizeChanged(SizeChangedInfo sizeInfo) at System.Windows.ContextLayoutManager.fireSizeChangedEvents() at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.UIElement.UpdateLayout() at System.Windows.Controls.TabItem.OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e) at System.Windows.UIElement.OnPreviewGotKeyboardFocusThunk(Object sender, KeyboardFocusChangedEventArgs e) at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed) at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed) at System.Windows.Input.KeyboardDevice.Focus(IInputElement element) at System.Windows.UIElement.Focus() at System.Windows.Controls.TabItem.SetFocus() at System.Windows.Controls.TabItem.OnMouseLeftButtonDown(MouseButtonEventArgs e) at System.Windows.UIElement.OnMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e) at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.ContentElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at System.Windows.Interop.HwndSource.InputFilterMessage(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)

adamsitnik commented 5 years ago

@grisharav how can I reproduce it?

grisharav commented 5 years ago

Unfortunately I can't share the full recording due to IP protection issues. It happened when I tried to view the flamegraph of .net virtual alloc stacks. Here's a screenshot of the data, not sure it will help: image

It doesn't happen for all recordings. My guess is that it's a matter of some numeric calculation inaccuracies and the size turned out negative in drawingContext.DrawRectangle( brush, null, // no Pen is crucial for performance new Rect(box.X, box.Y, box.Width, box.Height));

vancem commented 5 years ago

Adam will need a repro to make progress on the bug (or you could debug it). Note that it is likely that if you do a File -> Save it will save the view as an *.PerfView.XML.ZIP file. You can then unzip the file, and then edit it to rename anything that you view as IP to something else (although in most cases peoplemethod names interesting IP). Then open that modified PerfView.XML with PerfVIew and see that it repros. Then you can post that (now free of IP).

Note that if you do Right Click -> Drill Into after selecting a cell that represents only some of the samples you can create a new window with that subset to make the repro smaller (and thus the PerfView.XML file . Thus you may wish to do that first

grisharav commented 5 years ago

I have created a full memory dump file using procdump on this exception. It should provide you with all the info needed. PerfView.exe_181220_212613.dmp.zip

yahorsi commented 5 years ago

Seems I got it today. What I did:

  1. Denerated heap dump from the memory dump for several dumps
  2. Run diff between heap dumps
  3. Navigated to the FlameGraph tab

After I got the exception I have saved the perf view file using save as. And finally I put ut on my google drive and here is the link: https://drive.google.com/open?id=1kTCuVyHW33c87ynC1S71nzt7bi6B2Nk-