Skip to content

Exception thrown when clicking Datagrid header for sorting (repeatedly changing ItemsSource) #4080

Open
@omnilogix

Description

@omnilogix

Describe the bug

When attempting to sort the datagrid as described here: https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid_guidance/group_sort_filter, the app crashes. The number clicks required to crash the app varies from a few to a few dozen.

Steps to Reproduce

  • [ X] Can this be reproduced in the Sample App? (Either in a sample as-is or with new XAML pasted in the editor.) If so, please provide custom XAML or steps to reproduce. If not, let us know why it can't be reproduced (e.g. more complex setup, environment, dependencies, etc...)

Steps to reproduce the behavior:
Reunion_Demo3.zip

  1. Build and run the attached sample app
  2. Click on the datagrid "name" column header multiple times (1 to 50)
  3. Watch for the crash
    image

Microsoft.ui.xaml.dll!ctl::AutoPeg<struct IInspectable,0>::~AutoPeg<struct IInspectable,0>(void)
Microsoft.ui.xaml.dll!DirectUI::UIElement::ResetAutomationPeer()
Microsoft.ui.xaml.dll!DirectUI::UIElement::~UIElement(void)
Microsoft.ui.xaml.dll!ctl::ComObject<class DirectUI::Control>::`vector deleting destructor'(unsigned int)
Microsoft.ui.xaml.dll!ctl::ComBase::ReleaseImpl()
Microsoft.ui.xaml.dll!DirectUI::UIAffinityReleaseQueue::DoCleanup()
Microsoft.ui.xaml.dll!DirectUI::UIAffinityReleaseQueue::BuildTree()
Microsoft.ui.xaml.dll!DirectUI::BuildTreeService::BuildTrees()
Microsoft.ui.xaml.dll!AgCoreCallbacks::FrameworkCallbacks_PhasedWorkDistributor_PerformWork()
Microsoft.ui.xaml.dll!CCoreServices::NWDrawTree()
Microsoft.ui.xaml.dll!CCoreServices::NWDrawMainTree()
Microsoft.ui.xaml.dll!CWindowRenderTarget::Draw()
Microsoft.ui.xaml.dll!CXcpBrowserHost::OnTick()
Microsoft.ui.xaml.dll!CXcpDispatcher::Tick()
Microsoft.ui.xaml.dll!CXcpDispatcher::OnReentrancyProtectedWindowMessage()
Microsoft.ui.xaml.dll!CXcpDispatcher::WindowProc()
Microsoft.ui.xaml.dll!CDeferredInvoke::DispatchQueuedMessage()
Microsoft.ui.xaml.dll!Microsoft::WRL::Details::DelegateArgTraits<long (__cdecl ABI::Windows::Foundation::ITypedEventHandler_impl<ABI::Windows::Foundation::Internal::AggregateType<ABI::Microsoft::System::DispatcherQueueTimer *,ABI::Microsoft::System::IDispatcherQueueTimer *>,IInspectable *>::*)(ABI::Microsoft::System::IDispatcherQueueTimer *,IInspectable *)>::DelegateInvokeHelper<Microsoft::WRL::Implements<Microsoft::WRL::RuntimeClassFlags<2>,ABI::Windows::Foundation::ITypedEventHandler<ABI::Microsoft::System::DispatcherQueueTimer *,IInspectable *>,Microsoft::WRL::FtmBase>,<lambda_fbe4f38be23425399af0724cc79ee2d3> &,1,ABI::Microsoft::System::IDispatcherQueueTimer *,IInspectable *>::Invoke()
CoreMessagingXP.dll!Microsoft::WRL::Details::DelegateArgTraits<long ( Windows::Foundation::ITypedEventHandler_impl<struct Windows::Foundation::Internal::AggregateType<class Microsoft::System::DispatcherQueueTimer *,struct Microsoft::System::IDispatcherQueueTimer *>,struct IInspectable *>::*)(struct Microsoft::System::IDispatcherQueueTimer *,struct IInspectable *)>::DelegateInvokeHelper<struct Microsoft::WRL::Implements<struct Microsoft::WRL::RuntimeClassFlags<2>,struct Windows::Foundation::ITypedEventHandler<class Microsoft::System::DispatcherQueueTimer *,struct IInspectable *>,class Microsoft::WRL::FtmBase>,class <lambda_67362a0a5709a7b3d634a36a54ed7d36>,-1,struct Microsoft::System::IDispatcherQueueTimer *,struct IInspectable *>::Invoke(struct Microsoft::System::IDispatcherQueueTimer *,struct IInspectable *)
CoreMessagingXP.dll!Microsoft::WRL::InvokeTraits<-2>::InvokeDelegates<class <lambda_00d64a5d69eb8cd85a8562b0747f7e4a>,struct Windows::Foundation::ITypedEventHandler<class Microsoft::System::DispatcherQueueTimer *,struct IInspectable *> >(class <lambda_00d64a5d69eb8cd85a8562b0747f7e4a>,class Microsoft::WRL::Details::EventTargetArray *,class Microsoft::WRL::EventSource<struct Windows::Foundation::ITypedEventHandler<class Microsoft::System::DispatcherQueueTimer *,struct IInspectable *>,struct Microsoft::WRL::InvokeModeOptions<-2> > *)
CoreMessagingXP.dll!Microsoft::System::DispatcherQueueTimer::TimerCallback(void *)
CoreMessagingXP.dll!CFlat::SehSafe::Execute<<lambda_654db17c35df07198786f0867aa10de6>>()
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::TimeoutHandler::ImportAdapter$(class CFlat::Box$1<struct CFlat::FunctionPointerAndUserData$1<long (*)(void *)> > *)
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::TimeoutManager::Callback_OnDispatch(void)
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchNextItem(void)
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop(enum Microsoft::CoreUI::Dispatch::RunMode)
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::SystemCoreMessaging::Callback_OnGroupDispatch(enum Microsoft::CoreUI::Dispatch::SystemCoreMessaging$GroupPriority,struct CFlat::Ref<struct System::IntPtr>)
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::SystemCoreMessaging::NoContext_GroupDispatchHandler(enum Microsoft::CoreUI::Dispatch::SystemCoreMessaging$GroupPriority,void *)
CoreMessagingXP.dll!Microsoft::CoreUI::Dispatch::SystemCoreMessaging::NoContext_HighPriorityDispatchHandler(void *)
CoreMessaging.dll!Microsoft__CoreUI__DispatchGroupHandler$CallbackThunk(class System::Delegate *)
CoreMessaging.dll!Microsoft::CoreUI::DispatchGroupHandler::Invoke()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter_DoWork()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter_WindowProc()
user32.dll!UserCallWinProcCheckWow()
user32.dll!DispatchMessageWorker()
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::RunDesktopWindowMessageLoop()
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplication::StartDesktop()
Microsoft.ui.xaml.dll!DirectUI::FrameworkApplicationFactory::Start()
[External Code]
[Inline Frame] hostpolicy.dll!coreclr_t::execute_assembly(int) Line 89
	at D:\workspace\_work\1\s\src\installer\corehost\cli\hostpolicy\coreclr.cpp(89)
hostpolicy.dll!run_app_for_context(const hostpolicy_context_t & context, int argc, const wchar_t * * argv) Line 246
	at D:\workspace\_work\1\s\src\installer\corehost\cli\hostpolicy\hostpolicy.cpp(246)
hostpolicy.dll!run_app(const int argc, const wchar_t * * argv) Line 275
	at D:\workspace\_work\1\s\src\installer\corehost\cli\hostpolicy\hostpolicy.cpp(275)
hostpolicy.dll!corehost_main(const int argc, const wchar_t * * argv) Line 408
	at D:\workspace\_work\1\s\src\installer\corehost\cli\hostpolicy\hostpolicy.cpp(408)
hostfxr.dll!execute_app(const std::wstring & impl_dll_dir, corehost_init_t * init, const int argc, const wchar_t * * argv) Line 146
	at D:\workspace\_work\1\s\src\native\corehost\fxr\fx_muxer.cpp(146)
hostfxr.dll!`anonymous namespace'::read_config_and_execute(const std::wstring & host_command, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator<std::wstring>>,known_options_hash,std::equal_to<enum known_options>,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator<std::wstring>>>>> & opts, int new_argc, const wchar_t * * new_argv, host_mode_t mode, wchar_t * out_buffer, int buffer_size, int * required_buffer_size) Line 520
	at D:\workspace\_work\1\s\src\native\corehost\fxr\fx_muxer.cpp(520)
hostfxr.dll!fx_muxer_t::handle_exec_host_command(const std::wstring & host_command, const host_startup_info_t & host_info, const std::wstring & app_candidate, const std::unordered_map<enum known_options,std::vector<std::wstring,std::allocator<std::wstring>>,known_options_hash,std::equal_to<enum known_options>,std::allocator<std::pair<enum known_options const ,std::vector<std::wstring,std::allocator<std::wstring>>>>> & opts, int argc, const wchar_t * * argv, int argoff, host_mode_t mode, wchar_t * result_buffer, int buffer_size, int * required_buffer_size) Line 1001
	at D:\workspace\_work\1\s\src\native\corehost\fxr\fx_muxer.cpp(1001)
hostfxr.dll!fx_muxer_t::execute(const std::wstring host_command, const int argc, const wchar_t * * argv, const host_startup_info_t & host_info, wchar_t * result_buffer, int buffer_size, int * required_buffer_size) Line 566
	at D:\workspace\_work\1\s\src\native\corehost\fxr\fx_muxer.cpp(566)
hostfxr.dll!hostfxr_main_startupinfo(const int argc, const wchar_t * * argv, const wchar_t * host_path, const wchar_t * dotnet_root, const wchar_t * app_path) Line 61
	at D:\workspace\_work\1\s\src\native\corehost\fxr\hostfxr.cpp(61)
Demo3.exe!exe_start(const int argc, const wchar_t * * argv) Line 236
	at D:\workspace\_work\1\s\src\installer\corehost\corehost.cpp(236)
Demo3.exe!wmain(const int argc, const wchar_t * * argv) Line 302
	at D:\workspace\_work\1\s\src\installer\corehost\corehost.cpp(302)
[External Code]


Expected behavior

No crashing

Screenshots

image

Environment

NuGet Package(s):

Package Version(s):

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [ ] May 2020 Update (19041)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [ X] May 2020 Update (19041)
- [ ] Insider Build (xxxxx)

Device form factor:
- [X ] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio
- [ ] 2017 (version: )
- [ ] 2019 (version: )
- [X ] 2019 16.11 Preview (version:2 )

Additional context

The app does not actually perform any sorting, it just follows the guidelines for implementing sorting and sets the ItemsSource to null and then back to the original list to mimic the sorting update process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DataGrid 🔠Issues on DataGrid controlWinUI 💠Related to WinUI 3 Version or when paired with External can mean requires fix in WinUI 2/3.bug 🐛An unexpected issue that highlights incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions