From ddbe9719c938bf95ca68630a606b5349ab31fa4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 25 Aug 2025 20:54:47 +0200 Subject: [PATCH] [WINLOGON] Temporarily hack around a bug in PSEH for GCC Commit 51ee32f5f8 moved the `WNetClearConnections()` in the main Winlogon thread, where it now runs. `WNetClearConnections()` calls a 3rd-party module (nfs41_np.dll) that invokes `kernel32!OutputDebugStringA()`. The SEH usage pattern in `OutputDebugStringA()`, when compiled with GCC and PSEH, generates an erroneous chain of exception handlers, that, when running in an execution environment like that of winlogon.exe, triggers a crash. See CORE-20316 for more details and testing. As a temporary measure, hackfix away the problem by surrounding the `WNetClearConnections()` call in a `_SEH2_TRY/_SEH2_EXCEPT` block (the net effect is to "add" the missing exception handler entry). Hack for commit 51ee32f5f8 CORE-20307 CORE-20309 CORE-20316 --- base/system/winlogon/sas.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/base/system/winlogon/sas.c b/base/system/winlogon/sas.c index cb06557ee43..f085db14d6b 100644 --- a/base/system/winlogon/sas.c +++ b/base/system/winlogon/sas.c @@ -497,7 +497,13 @@ CloseAllConnections( { if (!Session->UserToken || !ImpersonateLoggedOnUser(Session->UserToken)) return; - WNetClearConnections(NULL); + _SEH2_TRY // Temporary HACK to avoid SEH crashes triggered by OutputDebugStringA() + { // calls from WNetClearConnections(). CORE-20307, CORE-20309, CORE-20316 + WNetClearConnections(NULL); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + {} + _SEH2_END; RevertToSelf(); }