Microsoft-ui-xaml: TreeView - AccessViolationException with SelectedItem

Created on 14 Aug 2020  ·  6Comments  ·  Source: microsoft/microsoft-ui-xaml

The TreeView still throws an AccessViolationException, in Microsoft.UI.Xaml 2.5.0-prerelease.200708003 despite issues #2405 and #2303 being reported as closed.

Steps to reproduce the bug
Here is a sample MainPage.xaml

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    x:Class="App1.MainPage">

    <StackPanel>
        <muxc:TreeView ItemsSource="{x:Bind Mode=OneWay, Path=List}"
                       SelectedItem="{x:Bind SelectedItem}"/>
    </StackPanel>
</Page>

And the code-behind MainPage.xaml.cs

namespace App1
{
    public sealed partial class MainPage : Page
    {
        private ObservableCollection<string> List { get; set; } = new ObservableCollection<string>()
        {
            "Item 1",
            "Item 2",
            "Item 3",
        };

        private string SelectedItem { get; set; }

        public MainPage()
        {
            this.InitializeComponent();
            SelectedItem = List[1];
        }
    }
}

Steps to reproduce the behavior:

  1. Launch App1.
  2. Observe it crash with the following exception:
An unhandled exception of type 'System.AccessViolationException' occurred in App1.exe
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

The program '[9000] App1.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

Expected behavior
The app doesn't crash and opens with the Item 2 selected.

Version Info

NuGet package version: Microsoft.UI.Xaml 2.5.0-prerelease.200708003


Windows app type:
| UWP | Win32 |
| :--------------- | :--------------- |
| Yes | |


| Windows 10 version | Saw the problem? |
| :--------------------------------- | :-------------------- |
| Insider Build (xxxxx) | |
| May 2020 Update (19041) | |
| November 2019 Update (18363) | Yes |
| May 2019 Update (18362) | |
| October 2018 Update (17763) | |
| April 2018 Update (17134) | |
| Fall Creators Update (16299) | |
| Creators Update (15063) | |


| Device form factor | Saw the problem? |
| :----------------- | :--------------- |
| Desktop | Yes |
| Xbox | |
| Surface Hub | |
| IoT | |

Additional context
It looks like nothing has been done to specifically fix the previous issues #2405 and #2303, which were assumed to have been fixed by other changes.

This crash is pretty bad, we cannot catch the exception, and it's critical to get to the bottom of those issues and have them fixed properly.

area-TreeView help wanted team-Controls

Most helpful comment

The issues #2405 and #2303 were fixed by the switch away from a regular property to a dependency property for SelectedItem, as those both hit an issue where the tracker_ref ended up in a bad state.

This bug is different to the other bugs, but is a bug none the less. @ranjeshj I would like to look into this issue.

All 6 comments

The issues #2405 and #2303 were fixed by the switch away from a regular property to a dependency property for SelectedItem, as those both hit an issue where the tracker_ref ended up in a bad state.

This bug is different to the other bugs, but is a bug none the less. @ranjeshj I would like to look into this issue.

Is there any ETA on when the fix will be available?

Is there any ETA on when the fix will be available?

@sis2004 Given that the fix is in master, it should be available in the next pre-release (couple of weeks time).

@ranjeshj and @StephenLPeters it's been more than 3 weeks since this issue has been closed. Any ETA on the next release? Is there any nightly build or something that I can use to test the fix?

we published a new pre release today! We had an issue slip through the cracks that was fixed this week which delayed the prerelease https://github.com/microsoft/microsoft-ui-xaml/releases/tag/v2.5.0-prerelease.200923002

Thanks, I have done a cursory test with the new release, and the issue didn't manifest itself. I'll let you know if we see this issue again.

Was this page helpful?
0 / 5 - 0 ratings