Address Sanitizer for VST3 plugin?

I’m having all kinds of problems trying to get Address Sanitizer to work for my VST3 plugin. Most of the time my plugin won’t even be recognized by the host (Studio One 5 or AudioPluginHost), and I keep getting this error in the output window, even though I have included the specified library in the arguments pane:

==5075==ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:

DYLD_INSERT_LIBRARIES=/Applications/Xcode11.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/lib/darwin/libclang_rt.asan_osx_dynamic.dylib

"interceptors not installed" && 0### Warning: UCNET:Outgoing socket is in error state!!!

The few times I did manage to get it working, before my plugin window would appear, I’d get a EXC_BAD_ACCESS in “__asan::Allocator::Deallocate”, with nothing but “start” in the call stack before that.

In the VST3 scheme, I have specified the host, and the custom working (VST3) directory, and tried with Debug Executable on or off, and with Launch Automatically or Wait for the executable to be launched, but I can’t seem to get it working once Address Sanitizer is turned on.

I know I’ve used this before (in an earlier OS and Xcode), but I can’t seem to figure out the secret formula for tracking down a heap corruption error I keep getting on the PC. (I had even more trouble trying to use ASan in VS2019, so I thought I’t try on the Mac, where I’m more comfortable.)

Any ideas?

The easiest way to get it working is to build both the plugin and the host with Address Sanitizer enabled. This is easy with the AudioPluginHost, but probably not viable for other hosts.

Yeah, I did build AudioPluginHost with AddressSanitizer, but it just says it failed to load the VST3 plugin when I try to instantiate it. Nothing in the Output window to tell me why, though.

Does the same thing when I try to load my NON-address sanitized VST3 plugin, though. No explanation in the Output window, whether I debug the plugin or debug the app itself. What could I be doing wrong that it won’t load my VST3? It loads the plugins it lists, but I don’t even SEE most of the plugins in my VST3 folder.

Huh. Opened my plugin after dragging&dropping it. Now I can select that first one in the list and it opens. I’ll try using the ASan version again now.

Is there a way to get audio to play? I need to capture audio with the “transport” running, but it looks like this host doesn’t have that concept? (I tried opening the Sampler (Internal) plugin, but nothing at all happens when I select that from the menu.)

Is there some other tool I can use? I can’t seem to get AddressSanitizer to help me find my heap corruption on either Mac or PC. :frowning:

I’m trying to use the ASAN on my VST3 and Reaper used as the debugging executable (as defined in the scheme) but I’m hitting ASAN errors as well.

The AudioPluginHost and my VST3 both compiled with ASAN work perfectly well, though. So, do you mean that’s probably normal, i.e. not my plugin’s fault?

It depends on the error.

If you’re getting the “AddressSanitizer is loaded too late error”, that’s to be expected, and can be worked around using the instructions in the error message.

If you’ve already followed those instructions, and are getting other error reports (use-after-free, heap-buffer-overflow etc.) those would probably indicate an issue in your plugin.

I just checked the AudioPluginDemo with ASAN enabled and Reaper and I get the same error:

I’ve disabled every other plugins in Reaper and the ASAN is triggered upon plugins scanning. That’s strange. This is latest Reaper (6.53) and JUCE 6.1.2. Would love to bring more info but I do not see any stack trace or symbols. Do you have any clue now that my plugin is exonerated :wink: ?

Well, just tried with NO plugins at all and same results, so there might be something with Reaper (or my Reaper setup).