Crashing Rack by trying to delete a module

Is there a common coding error that causes VCV Rack crashing if a module is being deleted?

As I see I clearly made such a mistake but reading my code I can’t see what went wrong. :frowning:

On this line (100):

lights[SEQ_1_LED_LIGHT-1+stepA].setBrightness(0)

You have circumstances where StepA = 0 so you will actually be accessing lights[-1]. I’m not sure how that isn’t failing at run time but I’ve had some funky behaviour when I have mistakenly accessed the lights, inputs and outputs arrays with out of bounds indexes.

Not saying that is the definite cause.

Check the log file after the crash, that may give you some clues as to where it’s actually happening.

Many thanks @CountModula for taking a look! I think you are right. Commenting out all .setBrightness() lines the module works fine. (Although I have absolutely no clue which step is active. :smiley: )

Anyway I need to study those “light-lines” carefully again…

1 Like

OK, I think it’ll work. Thank you again!

1 Like

It has always happened to me in Rack, on a semi-regular basis. It’s not too often and I guess I’ve just learned to ignore it. Downside of most C++ programs (ducks…).

1 Like

No, that’s fair. In C/C++ it’s very common to crash due to memory management issues. not really possible in a lot of other languages. That said, It is quite possible to avoid those kinds of bugs in C++. Don’t think any of my modules ever did that.

1 Like