From cd35bc5989305c191299e576e23b59db10403451 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Thu, 9 Jun 2022 14:48:28 -0500 Subject: [PATCH] Restore OpenConsoleProxyStub's dependency on the CRT to fix QI (#13254) When #13160 introduced a new interface to the IConsoleHandoff idl, it changed midl's RPC proxy stub lookup algorithm from a direct GUID comparison to an unrolled binary search. Now, that would ordinarily not be a problem... However, in #11610, we took a shortcut and replaced `memcmp` -- used only by RPC for GUID comparison -- with a direct GUID-only equality comparator. This worked totally fine, and ordinarily would not be a problem... The unrolled binary search unfortunately _relies on memcmp's contract_: it uses memcmp to match against a fully sorted set. Our memcmp only returned 0 or 1 (equal or not), and it knew nothing about ordering. When a package that contains a PackagedCOM proxy stub is installed, it is selected as the primary proxy stub for any interfaces it can proxy. After all, interfaces are immutable, so it doesn't matter whose proxy you're using. Now, given that we installed a *broken* proxy... *all* IIDs that got whacked by our memcmp issue broke for every consumer. To fix it: instead of implementing memcmp ourselves, we're just going to take a page out of WinAppSDK's book and link this binary using the "Hybrid CRT" model. It will statically link any parts of the STL it uses (none) and dynamically link the ucrt (which is guaranteed to be present on Windows.) Sure, the binary size goes up from 8k to 24k, but... the cost is never having to worry about this again. Closes #13251 --- .github/actions/spelling/expect/expect.txt | 2 - src/host/proxy/Host.Proxy.vcxproj | 56 ++++++++++++++++------ src/host/proxy/Host.Proxy.vcxproj.filters | 3 -- src/host/proxy/nodefaultlib_shim.h | 8 ---- 4 files changed, 41 insertions(+), 28 deletions(-) delete mode 100644 src/host/proxy/nodefaultlib_shim.h diff --git a/.github/actions/spelling/expect/expect.txt b/.github/actions/spelling/expect/expect.txt index dd4342d9d25..6e4f259dcea 100644 --- a/.github/actions/spelling/expect/expect.txt +++ b/.github/actions/spelling/expect/expect.txt @@ -959,7 +959,6 @@ guardxfg guc gui guidatom -guiddef GValue GWL GWLP @@ -1567,7 +1566,6 @@ NOCOLOR NOCOMM NOCONTEXTHELP NOCOPYBITS -nodefaultlib nodiscard NODUP noexcept diff --git a/src/host/proxy/Host.Proxy.vcxproj b/src/host/proxy/Host.Proxy.vcxproj index dd0551e104d..fc8ff483073 100644 --- a/src/host/proxy/Host.Proxy.vcxproj +++ b/src/host/proxy/Host.Proxy.vcxproj @@ -21,7 +21,7 @@ - REGISTER_PROXY_DLL;WIN32;%(PreprocessorDefinitions) NotUsing - Default - false - false - nodefaultlib_shim.h;%(ForcedIncludeFiles) OpenConsoleProxy.def - - - true - DllMain + + + + + + MultiThreadedDebug + + + + %(IgnoreSpecificDefaultLibraries);libucrtd.lib + %(AdditionalOptions) /defaultlib:ucrtd.lib + + + + + + MultiThreaded + + + + %(IgnoreSpecificDefaultLibraries);libucrt.lib + %(AdditionalOptions) /defaultlib:ucrt.lib + + + diff --git a/src/host/proxy/Host.Proxy.vcxproj.filters b/src/host/proxy/Host.Proxy.vcxproj.filters index 1cdf7ca2512..df6bcbd10c6 100644 --- a/src/host/proxy/Host.Proxy.vcxproj.filters +++ b/src/host/proxy/Host.Proxy.vcxproj.filters @@ -41,9 +41,6 @@ Header Files - - Header Files - diff --git a/src/host/proxy/nodefaultlib_shim.h b/src/host/proxy/nodefaultlib_shim.h deleted file mode 100644 index 4face4e49f2..00000000000 --- a/src/host/proxy/nodefaultlib_shim.h +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#pragma once - -#include - -#define memcmp(a, b, c) (!InlineIsEqualGUID(a, b))