VCVRack / rack-plugin-toolchain

56 stars 13 forks source link

std::mt19937 crashes with toolchain build on windows #8

Open squinkylabs opened 3 years ago

squinkylabs commented 3 years ago

Once again I've run into compatibility problem with the toolchain build in windows where it crashes with perectly good c++ code.

This time it's in mt19937. Calling it from my process(args) function corrupts the stack and crashes. Since I need to do this I may have to use an open-source implementation of the mersenne twister algorithm.

So far my problems are:

1) sometimes trying to catch an exception in draw code crashed the toolchain build (but not a local msys build). Solution: remove the code that does that.

2) using std::stringstream from draw code crashes with the toolchain build (but not a local msys build). Solution: wrote my own subset of stringstream that works.

3) [new] calling mt19937 from process call immediately crashes with a corrupt stack. solution: none yet.

cschol commented 3 years ago

Can you explain your use case for the mt19937? There are about 40 instances in plugins throughout the entire library of plugins. Maybe we can narrow down what is different with your code?

squinkylabs commented 3 years ago

Yeah, in this case I call it every now and then from my module's process function. I usually use a static instance of it, but I tried doing something more normal. There certainly could be something odd in my plugin that makes all these issues happen. I've had little luck isolating it so far, but I can try again. I never, ever have problems like these with my desktop builds - they always come up with toolchain builds. It certainly "acts" like the version of the c++ std library that the build toolchain uses is not compatibly with the compiled module.

In the past all my crashes were from doing things on the drawing thread, but this one is on the engine thread. I'll try to repro in a different plugin.