microsoft/aspire · error · Win32Exception

Failed to initialize process thread attribute list

Error message

Failed to initialize process thread attribute list

What it means

When the Aspire CLI spawns a process on Windows with an explicit inheritable-handle list or job assignment, it builds a PROC_THREAD_ATTRIBUTE_LIST via InitializeProcThreadAttributeList. This error is thrown when that native call returns false, wrapped with the last Win32 error. Without the attribute list the extended process-creation attributes (handle inheritance, job list) cannot be used.

Solutions

  1. Check the inner Win32Exception error code; ERROR_INSUFFICIENT_BUFFER usually means retry sizing — report as a bug if the CLI pre-computed attrListSize.
  2. Free up memory / address low-memory conditions on the machine.
  3. Verify the Windows version supports PROC_THREAD_ATTRIBUTE_LIST (Windows Vista+; effectively all supported systems).
  4. Update the Aspire CLI — a marshalling/size bug would be a CLI defect to report.
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    var pi = WindowsProcessInterop.CreateProcessWithAttributes(...);
}
catch (Win32Exception ex)
{
    logger.LogError(ex, "Attribute list init failed (Win32 error {Code}); falling back to plain CreateProcess.", ex.ErrorCode);
}

Prevention

When it happens

Trigger: Calling WindowsProcessInterop process-creation helpers (e.g. when starting a child process with killOnParentExit: true or explicit handle inheritance) where InitializeProcThreadAttributeList fails with the requested attributeCount.

Common situations: Memory exhaustion (AllocHGlobal succeeded but the native init failed); malformed attribute count calculations after marshalling changes; running on very old or stripped Windows versions; interference from security software hooking process-creation APIs.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/a267cab2f9f69631. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Cli/Processes/WindowsProcessInterop.cs:392

            }
        }
        AddIfUnique(stdio.Stdin);
        AddIfUnique(stdio.Stdout);
        AddIfUnique(stdio.Stderr);

        // The child always needs the stdio handle whitelist; when a parent-lifetime job is supplied it
        // ALSO needs PROC_THREAD_ATTRIBUTE_JOB_LIST so the child is assigned to the job atomically at creation (below).
        var attributeCount = jobHandle is not null ? 2 : 1;

        var attrListSize = nint.Zero;
        InitializeProcThreadAttributeList(nint.Zero, attributeCount, 0, ref attrListSize);

        var attrList = Marshal.AllocHGlobal(attrListSize);
        try
        {
            if (!InitializeProcThreadAttributeList(attrList, attributeCount, 0, ref attrListSize))
            {
                throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Failed to initialize process thread attribute list");
            }

            try
            {
                var handles = inheritable.ToArray();
                var pinnedHandles = GCHandle.Alloc(handles, GCHandleType.Pinned);
                var pinnedJobHandles = default(GCHandle);
                var jobHandleRefAdded = false;

                try
                {
                    if (!UpdateProcThreadAttribute(
                        attrList,
                        0,
                        ProcThreadAttributeHandleList,
                        pinnedHandles.AddrOfPinnedObject(),
                        (nint)(nint.Size * handles.Length),
                        nint.Zero,

View on GitHub (pinned to 25830f84bd)