setLocal

Dear team,

I find myself once again spending an afternoon trying to decypher the setlocal build error.

I would kindly request that this post-build script needs a rewrite to handle and print intelligible error report at the point where the error occurs rather than dumping the whole script as error message. Reporting the whole script as MSB3073 and generic C0000005 (-1,073,741,819) is really unhelpful.

I understand there are many threads on this topic and a dedicated article in the docs. But none of that covers even a proportion of ways things can go wrong in this script.

Here is the offending script. All I’m asking is to put our “coding standards” lens and look at this:

setlocal
"C:\Program Files\CMake\bin\cmake.exe" -E copy C:/apps/VST_SDK/vst3sdk/cmake/modules/../templates/VST_Logo_Steinberg.ico C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/PlugIn.ico
if %errorlevel% neq 0 goto :cmEnd
"C:\Program Files\CMake\bin\cmake.exe" -E copy C:/apps/VST_SDK/vst3sdk/cmake/modules/../templates/desktop.ini.in C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/desktop.ini
if %errorlevel% neq 0 goto :cmEnd
attrib +s C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/desktop.ini
if %errorlevel% neq 0 goto :cmEnd
attrib +s C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/PlugIn.ico
if %errorlevel% neq 0 goto :cmEnd
attrib +s C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
cd C:\Users\user\Documents\vst\pluginName\build\bin
if %errorlevel% neq 0 goto :cmEnd
C:
if %errorlevel% neq 0 goto :cmEnd
C:\Users\user\Documents\vst\pluginName\build\bin\Debug\moduleinfotool.exe -create -version 1.0.0.1 -path C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3 -output C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/Contents/Resources/moduleinfo.json
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
setlocal
cd C:\Users\user\Documents\vst\pluginName\build\bin
if %errorlevel% neq 0 goto :cmEnd
C:
if %errorlevel% neq 0 goto :cmEnd
"C:\Program Files\CMake\bin\cmake.exe" -E echo [SMTG] Validator started...
if %errorlevel% neq 0 goto :cmEnd
C:\Users\user\Documents\vst\pluginName\build\bin\Debug\validator.exe C:/Users/user/Documents/vst/pluginName/build/VST3/Debug/pluginName.vst3/Contents/x86_64-win/pluginName.vst3
if %errorlevel% neq 0 goto :cmEnd
"C:\Program Files\CMake\bin\cmake.exe" -E echo [SMTG] Validator finished.
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd

Simply, when something goes wrong it’s impossible to tell which command failed or why.

Many thanks in advance

1 Like

It seems that your plugin crash during validation. In order to get a better debugging you could add in the Project Properties=>Debugging => Command : the path to the validator.exe and in the Command Arguments the path to your plugin.vst3

Start the debugger (F5) to fix your plugin check.
Maybe you have to disable the Post-Build Event

Hi Ubuuntu,

I have had this issue also. I haven’t tried Yvan’s suggestion above, so what I say is probably redundant.

I have found through trial and error that the SetLocal error is mostly caused by the differencing of a nullpointer provided by the framework. For example, the eventsList, data.outputs.audiobuffer64/32 etc.

My uneducated assumption is that the validator also tests the plugin with 0 inputs, 0 blocksize, 0 events, and so results in dereferenced nullptrs unless they are tested.

My way to stop this has been to follow the way the framework handles these pointers. In that I make sure to have a test or guard for every core framework pointer before it is passed to a function etc. So for example:

  • Wrapping events handling logic in if(inputevents.numEvents > 0)
  • Wrapping buffer filling logic in tests for the pointer not being null if(data.numOutputs > 0) etc

Indeed I believe blocksizes and channel counts of zero are legal as far as the implementation on DAW side, and so these are good to have regardless