Skip to content

Add ASan support for MSVC #6964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Add ASan support for MSVC #6964

wants to merge 2 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented May 9, 2021

As of VS 16.9, there is native support for ASan in the MSVC toolchain.
Although it is already possible to enable that by adding the respective
option to CFLAGS, we make it available via the configure option
--enable-sanitizer which is only used for clang builds on Windows so
far.

We also disable the manual inclusion of ASan headers, since these are
available by default. We use the more general __SANITIZE_ADDRESS__
for detection of ASan, to avoid a bogus warning, when _setmaxstdio()
is called.


TODO:

  • fix configure help message
  • enable for CI (nightly)?

@cmb69 cmb69 changed the title Add ASan support for VS Add ASan support for MSVC May 9, 2021
@nikic
Copy link
Member

nikic commented May 10, 2021

Awesome!

@cmb69
Copy link
Member Author

cmb69 commented Jul 4, 2021

I'm getting a lot of 0xc0000028 (STATUS_BAD_STACK, i.e. "An invalid or unaligned stack was encountered during an unwind operation."), e.g. for Zend/tests/030.phpt. I think this is bogus, but I wouldn't know how to suppress it (note that this is from MSVC, not from ASan). Any ideas?

@nikic
Copy link
Member

nikic commented Jul 5, 2021

My first guess would be something to do with frame pointer elimination. Would passing /Oy- do something?

@cmb69
Copy link
Member Author

cmb69 commented Jul 12, 2021

Would passing /Oy- do something?

At least not on x64 (tested; didn't test on x86). :(

cmb69 added 2 commits July 18, 2021 00:00
As of VS 16.9, there is native support for ASan in the MSVC toolchain.
Although it is already possible to enable that by adding the respective
option to `CFLAGS`, we make it available via the configure option
`--enable-sanitizer` which is only used for clang builds on Windows so
far.

We also disable the manual inclusion of ASan headers, since these are
available by default.  We use the more general `__SANITIZE_ADDRESS__`
for detection of ASan, to avoid a bogus warning, when `_setmaxstdio()`
is called.
These are likely bogus, but that issue should be investigated when
there is time; for now we just ignore it to make progress.
@cmb69
Copy link
Member Author

cmb69 commented May 4, 2022

Note to self: test with Control Flow Guard disabled.

@cmb69
Copy link
Member Author

cmb69 commented Sep 22, 2024

Superseded by #15978.

@cmb69 cmb69 closed this Sep 22, 2024
@cmb69 cmb69 mentioned this pull request Sep 22, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants