[all-commits] [llvm/llvm-project] 41b09b: [ASAN][sanitizers][win] Allow windows-asan to be b...

Charlie Barto via All-commits all-commits at lists.llvm.org
Tue Jan 16 13:19:16 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 41b09bbe98fc8d5952beeeb34fcb07caeecfbdcb
      https://github.com/llvm/llvm-project/commit/41b09bbe98fc8d5952beeeb34fcb07caeecfbdcb
  Author: Charlie Barto <chbarto at microsoft.com>
  Date:   2024-01-16 (Tue, 16 Jan 2024)

  Changed paths:
    M compiler-rt/lib/asan/asan_win.cpp
    M compiler-rt/lib/interception/interception_win.cpp

  Log Message:
  -----------
  [ASAN][sanitizers][win] Allow windows-asan to be built with /MDd and intercept functions from the debug runtimes. (#77840)

It turns out this works _mostly_ fine, even when mixing debug versions
of asan with programs built with the release runtime. Using /MT (or
/MTd) with a dynamically linked asan has never really worked that well,
and I am planning on opening a PR that will completely remove the
static-asan configuration for windows and make programs linked with the
static CRT/runtime work with the DLL version of asan. This is better
than the current situation because the static linked version of asan
doesn't work well on windows if there are multiple DLLs in the process
using it.

The check for building asan with only /MD or /MT has been removed. It
was in AsanDoesNotSupportStaticLinkage, but was checking for debug CRTs,
not static linkage. The kind of static linkage this function is supposed
to check for (on linux for example) doesn't really exist on windows.

Note: There is one outstanding issue with this approach, if you mix a
/MDd DLLs and /MD dlls in the same process then the "real" function
called by asan interceptors will be the same for calls from both
contexts, potentially screwing up things like errno. This only happens
if you mix /MD and /MDd in the same process, because otherwise asan
won't find functions from both runtimes to intercept. We are working on
a fix for this, and it mainly hits with the CRT functions exported from
both ucrtbase and ntdll.


This change is being upstreamed from Microsoft's fork.




More information about the All-commits mailing list