How to use AddressSanitizer with VS 2019 (crash)

I’m trying to use this for the first time, and encountering a crash. I want to debug my plugin in the AudioPluginHost. I’m assuming that the APH must be rebuilt with AS on, as do each project in the solution (the shared library, the plugin VST and VST3 etc.)?

Anyway, I tried rebuilding the APH with AS enabled (Properties > C++/General) AS on.

When I launch just the APH, I get this crash. I also get a crash like this trying to run my plugin compiled with AS (with an APH that has it off):

exception

PS. is there a setting for this in the Projucer that must be enabled?

Take a look at the section on ‘debugging’ here: https://devblogs.microsoft.com/cppblog/asan-for-windows-x64-and-debug-build-support/#known-issues

This is expected behaviour, and the exceptions are recoverable. You can configure Visual Studio to automatically continue past this sort of exception.

Thanks, I will certainly try that. Can you confirm that, if you have a VS Solution that has your:

  • Plugin_SharedCode Project
  • Plugin_VST Project
  • Plugin_VST3 Project
  • Something_StaticLibrary

you need to set all of those projects Properties individually to use ASan?

And if you want to debug into the AudioPluginHost, you need to compile that with ASan as well?

So I disabled the 0xC0000005 exception as the doc you linked explained.

I am testing this first on a JUCE Gui App.

The first thing that hits now is an Exception Unhandled: use of out-of-scope stack memory, on a juce library function, apparently when trying to load the JUCE splash screen. Does this make any sense?

I’m not sure exactly what’s going on here. I can reproduce the issue, but only on MSVC, so I think there’s a chance this is a false positive. Asan is experimental on MSVC at the moment, after all.

I found that I could work around this issue by modifying character pointers in-place, so I’ve made that change on the develop branch now: