We (Microsoft) have a bunch of changes on top of LLVM-14 to enable asan to work on windows with msvc. We'd like to start working in the open, on LLVM main, but our branch has diverged somewhat. We've thrown some changesets over the wall previously and I'm going to be resuming the effort.
In any event this is a very self-contained set of fixes to interception. It intercepts _strdup on windows instead of strdup and changes the way memcpy is intercepted on I386 windows. For strdup windows does not define an actual strdup function, only _strdup (because strdup is in POSIX, not C, until C23). Note that _strdup_dbg ends up calling _strdup. For memcpy the behavior is changed on I386 windows to intercept with asan's version of memmove. On I386 windows memcpy and memmove are actually separate functions, even though they have identical implementations, thus memcpy needs to be intercepted with asan's memmove to avoid having asan check for overlapping ranges, which could break programs relying on this behavior (this is a bit of a judgement call though, we think preserving the memmoving behavior of memcpy makes asan more useful for catching real bugs, but our memcpy isn't actually documented as being memmove on all architectures.)
[asan][win][msvc] Intercept memcpy in addition to memmove on i386 windows.
[asan][win][test] Add tests ensuring memcpy and memmove are properly intercepted on windows
In line with our conversation yesterday, we'd prefer to not lose the memcpy/memmove distinction when it comes to diagnostics; we still want to diagnose: