{"record":{"id":"bd2ce7dfc0803b0a","repo":"microsoft/aspire","slug":"failed-to-invoke-initializeprocthreadattributelist-while","errorCode":null,"errorMessage":"Failed to invoke InitializeProcThreadAttributeList while starting tracked browser CDP pipe.","messagePattern":"Failed to invoke InitializeProcThreadAttributeList while starting tracked browser CDP pipe\\.","errorType":"exception","errorClass":"Win32Exception","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Browsers/BrowserLogsPipeBrowserProcessLauncher.Windows.cs","lineNumber":88,"sourceCode":"    }\n\n    private static WindowsProcessInfo CreateWindowsProcess(string executablePath, IReadOnlyList<string> arguments, IntPtr[] inheritedHandles)\n    {\n        var commandLine = Marshal.StringToHGlobalUni(BuildWindowsCommandLine(executablePath, arguments));\n        var attributeListSize = UIntPtr.Zero;\n        // STARTUPINFOEX + PROC_THREAD_ATTRIBUTE_HANDLE_LIST lets us turn on handle inheritance while limiting it to the\n        // two CDP pipe handles. That avoids the broad \"all inheritable handles leak into Chromium\" behavior of plain\n        // CreateProcess(..., inheritHandles: true).\n        _ = InitializeProcThreadAttributeList(IntPtr.Zero, 1, 0, ref attributeListSize);\n        var attributeList = Marshal.AllocHGlobal((nint)attributeListSize.ToUInt64());\n        var handleList = Marshal.AllocHGlobal(IntPtr.Size * inheritedHandles.Length);\n        var startupInfoPointer = IntPtr.Zero;\n\n        try\n        {\n            if (!InitializeProcThreadAttributeList(attributeList, 1, 0, ref attributeListSize))\n            {\n                throw CreateWindowsException(\"InitializeProcThreadAttributeList\");\n            }\n\n            for (var i = 0; i < inheritedHandles.Length; i++)\n            {\n                Marshal.WriteIntPtr(handleList, i * IntPtr.Size, inheritedHandles[i]);\n            }\n\n            if (!UpdateProcThreadAttribute(\n                attributeList,\n                0,\n                s_procThreadAttributeHandleList,\n                handleList,\n                (UIntPtr)(uint)(IntPtr.Size * inheritedHandles.Length),\n                IntPtr.Zero,\n                IntPtr.Zero))\n            {\n                throw CreateWindowsException(\"UpdateProcThreadAttribute\");\n            }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Browsers/BrowserLogsPipeBrowserProcessLauncher.Windows.cs#L70-L106","documentation":"A Win32Exception wrapping GetLastError from InitializeProcThreadAttributeList in CreateWindowsProcess (BrowserLogsPipeBrowserProcessLauncher.Windows.cs:88). Aspire uses an extended STARTUPINFO attribute list to restrict handle inheritance to exactly the two CDP pipe handles when launching Chromium; failure here means the attribute list could not be prepared, so the browser cannot be started on the pipe transport.","triggerScenarios":"InitializeProcThreadAttributeList returns FALSE during StartWindows — typically ERROR_INSUFFICIENT_BUFFER (size mismatch after AllocHGlobal) or ERROR_NOT_ENOUGH_MEMORY when the heap allocation cannot back the list.","commonSituations":"Severe memory pressure on the host; corrupted kernel32 state after unusual injection/hooking software (antivirus, App-V); essentially never caused by user configuration.","solutions":["Read NativeErrorCode (ex.Message includes the Win32 error) and check system memory availability.","Retry after freeing memory or increasing the machine/container memory limit.","Disable or exclude injective antivirus/EDR hooking of process creation for the AppHost process.","Run the latest Aspire version; if persistent, report at https://github.com/microsoft/aspire/issues with the Win32 error code.","Consider the WebSocket CDP transport as a fallback if the pipe transport cannot start."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"static bool IsInitAttrListFailure(Win32Exception ex) => ex.Message.Contains(\"InitializeProcThreadAttributeList\");","tryCatchPattern":"try\n{\n    StartBrowserPipeWindows();\n}\ncatch (Win32Exception ex) when (IsInitAttrListFailure(ex))\n{\n    logger.LogError(ex, \"InitializeProcThreadAttributeList failed (Win32 error {Errno}). Check memory and security software.\", ex.NativeErrorCode);\n    throw;\n}","preventionTips":["Keep sufficient free memory on Windows hosts/containers.","Exclude the AppHost from injective antivirus/EDR hooks on process creation.","Keep Aspire and the .NET runtime up to date.","Fall back to the WebSocket CDP transport if pipe launch keeps failing."],"tags":["windows","win32","process-launch","browser"],"backgroundTag":"process-spawn-failed","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}