Skip to content

When start an app, there is a WinRT error 0x8007007A: "The data area passed to a system call is too small." raised while calling FindPackagesByPackageFamily #6274

@hoshiizumiya

Description

@hoshiizumiya

Describe the bug

We checked all the box for 'Break when thrown' in the exception settings firstly. And when start the app, as the screenshot: FindPackagesByPackageFamily reported insufficient buffer (ERROR_INSUFFICIENT_BUFFER / HRESULT 0x8007007A). The debugger locals show bufferLength = 80 and corrupted locals (huge vector size, invalid pointer), which indicates a buffer overflow / memory corruption after the API wrote into the caller-supplied buffer. The common root cause here is allocating the buffer with the wrong unit: FindPackagesByPackageFamily returns a required character count for a PWSTR buffer, but the code likely allocated bufferLength bytes (not bufferLength * sizeof(wchar_t)), or otherwise passed a buffer too small. That causes the API to write past the allocation, corrupting nearby stack/heap state and turning the insufficient-buffer condition into undefined behavior and an originating WinRT error. Also verify you properly handle the API return codes (treat ERROR_INSUFFICIENT_BUFFER specially) and only use the buffer after a successful second call.

Steps to reproduce the bug

A blank WinUI3 C++ project is ok.
Checked all the box for 'Break when thrown' in the exception settings.
And get the exception.

Expected behavior

No response

Screenshots

Image

NuGet package version

Windows App SDK 1.8.5: 1.8.260209005

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 24H2 LTSC (26100, June Update), Insider Build (xxxxx), Windows 11 version 24H2 (26100, June 2025 Update)

IDE

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ExternalTopics external to Windows App SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions