{"record":{"id":"48ba274333f5e4ce","repo":"File-New-Project/EarTrumpet","slug":"process-is-a-zombie-processid-48ba27","errorCode":null,"errorMessage":"Process is a zombie: {processId}","messagePattern":"Process is a zombie: (.+?)","errorType":"exception","errorClass":"ZombieProcessException","httpStatus":null,"severity":"error","filePath":"EarTrumpet/DataModel/AppInformation/Internal/ModernAppInfo.cs","lineNumber":143,"sourceCode":"\r\n                        Kernel32.OpenPackageInfoByFullName(packageFullName, 0, out IntPtr packageInfoReference);\r\n\r\n                        int bufferLength = 0;\r\n                        Kernel32.GetPackageApplicationIds(packageInfoReference, ref bufferLength, IntPtr.Zero, out int appIdCount);\r\n\r\n                        buffer = Marshal.AllocHGlobal(bufferLength);\r\n                        Kernel32.GetPackageApplicationIds(packageInfoReference, ref bufferLength, buffer, out appIdCount);\r\n\r\n                        appUserModelId = Marshal.PtrToStringUni(Marshal.ReadIntPtr(buffer));\r\n                        Marshal.FreeHGlobal(buffer);\r\n\r\n                        Kernel32.ClosePackageInfo(packageInfoReference);\r\n                    }\r\n                }\r\n            }\r\n            else\r\n            {\r\n                throw new ZombieProcessException(processId);\r\n            }\r\n\r\n            return appUserModelId;\r\n        }\r\n\r\n        private static bool CanResolveAppByApplicationUserModelId(string aumid)\r\n        {\r\n            try\r\n            {\r\n                Shell32.SHCreateItemInKnownFolder(FolderIds.AppsFolder, Shell32.KF_FLAG_DONT_VERIFY, aumid, typeof(IShellItem2).GUID);\r\n                return true;\r\n            }\r\n            catch (Exception ex)\r\n            {\r\n                Trace.WriteLine($\"{ex}\");\r\n                return false;\r\n            }\r\n        }\r","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/File-New-Project/EarTrumpet/blob/aa894e51c22f5f9a939b31b224c4d2d3e163416e/EarTrumpet/DataModel/AppInformation/Internal/ModernAppInfo.cs#L125-L161","documentation":"ModernAppInfo.GetAppUserModelIdByPid resolves the AUMID for a packaged (UWP/Store) audio process. Unlike the desktop path there is no NtQuery fallback: if Kernel32.OpenProcess returns a zero handle for the PID, it immediately throws ZombieProcessException because without a process handle it cannot call GetApplicationUserModelId.","triggerScenarios":"Constructing ModernAppInfo for a PID whose packaged process cannot be opened (terminated, suspended-then-terminated, or access denied). OpenProcess returns IntPtr.Zero and the else branch throws.","commonSituations":"A UWP app was suspended/terminated by the OS but its audio session lingers; the packaged process crashed; querying a PID after it exited; insufficient rights to open the packaged process.","solutions":["Wrap ModernAppInfo construction in try/catch (ZombieProcessException) and drop the stale session.","Pre-check the process with Process.GetProcessById or a WaitForSingleObject probe before constructing.","Do not retry indefinitely; a zero handle for a packaged process almost always means it is gone.","Confirm the PID still maps to a packaged process via PackageManager if you need to distinguish dead-vs-access-denied."],"exampleFix":"// before\nvar info = new ModernAppInfo(pid, trackProcess: true);\n\n// after\ntry { info = new ModernAppInfo(pid, trackProcess: true); }\ncatch (ZombieProcessException) { return; } // packaged process gone","handlingStrategy":"try-catch","validationCode":"bool Alive(int pid)\n{\n    try { using (var p = Process.GetProcessById(pid)) { return !p.HasExited; } }\n    catch (ArgumentException) { return false; }\n    catch (InvalidOperationException) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { info = new ModernAppInfo(pid, trackProcess); } catch (ZombieProcessException ex) { Trace.WriteLine($\"Dead packaged process {pid}: {ex}\"); info = null; }","preventionTips":["ModernAppInfo has no fallback path — a zero OpenProcess handle is fatal; always catch.","Pre-check the PID when you suspect a suspended/terminated UWP process.","Suppress stale packaged-app sessions from the UI on this exception."],"tags":["process","win32","zombie","appinfo","uwp","interop","aumid"],"backgroundTag":null,"analyzedSha":"aa894e51c22f5f9a939b31b224c4d2d3e163416e","analyzedAt":"2026-08-13T18:51:30.564Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}