overdrivenpotato / rust-vst2

VST 2.4 API implementation in rust. Create plugins or hosts.
MIT License
223 stars 23 forks source link

Fixed plugin crashes on Windows by changing the calling convention to cdecl #12

Closed Boscop closed 8 years ago

Boscop commented 8 years ago

I finally tracked down what was causing the stack corruption when loading a Rust VST in a C++ host on Windows. When I debugged it in Visual Studio I got: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. So I found out that the VST SDK specifies cdecl as the calling convention to use.. And when I changed it, it finally worked..

Btw, I debugged it by compiling building this in debug mode: https://github.com/teragonaudio/MrsWatson And then it crashed on this line: https://github.com/teragonaudio/MrsWatson/blob/master/source/plugin/PluginVst2xWindows.cpp#L105

(Btw, I made the bit flags public to be compatible with bitflags 0.5.0)

overdrivenpotato commented 8 years ago

Had to test this out to make sure it was still correct on OS X, good find! :+1: