Skip to content

AppInstance.UnregisterKey() causes a failfast crash when called on a different thread than FindOrRegisterForKey(...) was called from #6447

@contextfree

Description

@contextfree

Describe the bug

When I call AppInstance.UnregisterKey() from a different thread than FindOrRegisterForKey(...) was called from, for me it consistently immediately crashes the process with a 0xc0000409 code. It seems to happen when trying to reset a mutex, m_keyCreationMutexLock, inside UnregisterKey().

If this is intended/expected behavior, it should at least be called out in the documentation for FindOrRegisterForKey and UnregisterKey. This was very frustrating to debug.

Steps to reproduce the bug

Minimal reproduction:
`

        AppInstance.FindOrRegisterForKey("key");
        Thread.Sleep(3000);
        new Thread(() =>
        {
            AppInstance.GetCurrent().UnregisterKey();
        }).Start();`

Expected behavior

The key will be registered and unregistered, without crashing the process.

Screenshots

No response

NuGet package version

2.0.1

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 24H2 (26100, June 2025 Update)

IDE

Other

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-LifecycleTopics related to the AppLifecycle, providing lifecycle management for WindowsAppSDK appsneeds-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions