Skip to content

DivideByZeroException in VirtualizingStackPanel after WM_STYLECHANGED #6225

@milos12345

Description

@milos12345
  • .NET 4.8
  • Windows version: 10.0.22000.0 and 10.0.19043.0 and all other

Problem description:
I am capturing WM messages in a rolling buffer and on program crash I get see these preceding most crashes

WM_STYLECHANGING
WM_STYLECHANGED
WM_STYLECHANGING
WM_STYLECHANGED

The program crashes with

System.DivideByZeroException: Attempted to divide by zero.
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverrideImpl(Size constraint, Nullable`1& lastPageSafeOffset, List`1& previouslyMeasuredOffsets, Nullable`1& lastPagePixelSize, Boolean remeasure)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
  at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
  • Crashes 1/100 runs
  • No my code in stack trace
  • I tried to set MinWidth/MinHeight in everything that goes in any scrollviewer, but I still get these crashes
    Are the window messages related and how would they cause this (or just they cause the remeasurement)?
    How would I go about finding the culprit/workaround?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions