Module in Library is buggy, local compile is not...

Hi all, I recently released my plugin (Sm@rTAZZ Studio Free), containing a Splitter module. The module works fine when using the one locally compiled, but the released one has glitches. I compared the source code of the released one and my locally compiled version…no difference…

Other modules in the same plugin do not seem to suffer from any difference…

I am developing on WIndows 11 with VCV Rack Pro. I use a different slug name for my local compiles, so I can see both the released Library versions as well as my local compiled ones.

Has anyone seen something similar? Being a newby in VCV rack development, I am pretty sure I am doing something wrong here, but I cannot figure it out…

All hints are appreciated!

1 Like

I have in the past had issues there my module in the library would crash VCV, but a local build would not. I think it’s some random bug in my old modules.

I was always able to work around it, but part of that was installing the “real” plugin build toolchain so that I could make builds exactly like the library does.

Differences in functionality is strange. Could you post a link to your github where the source code lives? Are you usure that’s the only difference? It’s not that running multiple copies glitches?

Hi Squinky, appreciate your response…My git link is here: GitHub - mlaban64/STS-Free: Sm@rTAZZ Studio Free VCV Rack2 Modules

Multiple copies is not the issue, as I see this with just a single instance of the library version, no local instance in the patch…

I’ll have a go at using the toolchain, although I understand this will require a Linux environment. I do have one, but that is set up with a GNU CC beta version (14.0), so not sure if that will fly…

Hi @Squinky,

I think I have found the issue, as I was able to reproduce the glitch finally in both “versions”…It is not straightforward to reproduce it consistently, hence I thought the local compiled version was doing fine…after all, it suffers from the same issue, once you know how to reproduce it…

It looks like it is caused by using a macro to swap two variable values, which uses a local static auto variable. I have seen issues with local variables in the process function of a module before, whilst declaring the variable at the class level does not cause any issues. Not sure why that is though…

Anyway, I’ll refactor the code and do some more testing…thanks for all the help!

Local auto or local static auto?

Very unlikely you would want a local static for a swap. There’s only one of them in the process space.

Oh also std::swap will do what you want most of the time

There’s nothing particularly weird in your code. And I don’t see why a local variable would be problematic - we all use them all the time.

Is it possible you just have some mystery bug that moves around as you change code, and it’s not related to swapping at all?

btw, you don’t need to write your own debug output function. The rack provided INFO macro works just fine. There’s certainly no need to open and close an output thing for each message output. I think stderr and such stay open all the time?

Hi @Squinky, thanks for these tips…clearly, I am a newby in VCV Rack, so appreciating the guidance here. I’ll refactor & test accordingly…The open/close I did was to enforce a flush of the I/O cache…not doing that would leave a number of lines in cache, so let me work with INFO, as that probably is a lot better than this querky hack…

The swap macro I used looked like this:

#define sts_swap(a,b) {static auto tmp = a; a = b; b = tmp;}

It might be that the "static " is causing problems, not sure how thread-safe/multi-entrant a plug-in is, when you have multiple instances…As said, I saw some weird stuff in the past, like when turning a knob on one of my modules, the same know would move in sync on another instance of that same module…

As said, some testing to be done…

Hi @baconpaul,

Thanks for this, I’ll have a go at the std::swap function to see if that also circumvents the problem. My macro looked like this:

#define sts_swap(a,b) {static auto tmp = a; a = b; b = tmp;}

When replacing it by code using a class-wide variable instead of tmp, the issue was resolved…

If you have your threads set to more than one in the audio engine, then for sure you could have different instance on different threads, so that in theory could do it with multiple instances. For sure it’s bad. In general, don’t make static variables. Still don’t see how that would cause your problem…

If you called that swap in you ui and your engine it would break even with one thread. Don’t make that variable static! But also use std swap instead since the std library specializes it where it can.

Hi @baconpaul,

I only used my swap macro in process(), nowhere else, but you’re right to point out I should use std:: functions where I can…as said, new to VCV Rack and also to C++…

Thanks for the tips & tricks!

Right! Well a good rule of thumb when starting out in rack is if you type static you have probably made a mistake. There’s exceptions to this but not many.

Have fun developing your modules!