Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange errors when loading (win32) VSTs #16

Open
Boscop opened this issue Jun 28, 2016 · 3 comments
Open

Strange errors when loading (win32) VSTs #16

Boscop opened this issue Jun 28, 2016 · 3 comments

Comments

@Boscop
Copy link
Contributor

Boscop commented Jun 28, 2016

I was writing a VST scanner that goes over all VSTs in my VST folder and calls get_info() on them.
Btw, all my VSTs are Win32 and mostly free ones.
After my scanner has processed a couple of VSTs, it crashes on some VSTs, but not always the same one on different runs. Also the way it crashes is different. Sometimes I get thread panicked at 'Error code 126' (ERROR_MOD_NOT_FOUND), sometimes I get thread panicked at 'Error code 1411' upon unloading (which is ERROR_CLASS_DOES_NOT_EXIST according to MSDN).
It looks like these are maybe 2 different problems: One that occurs directly when loading a plugin (error 126), and one that only occurs after loading and unloading a couple of plugins, and then it occurs when unloading another plugin (but it happens on different plugins on different runs).
The second problem seems to be related to the way plugins are unloaded. E.g. the access violation happened on line 959 (right after FreeLibrary) here: http://pastebin.com/NQpUd3sm
Sometimes it freezes (like in an infinite loop), sometimes I get an access violation right after FreeLibrary on the plugin was called. (When it's frozen / in an infinite loop and I kill it, it's still visible in process explorer as suspended. Probably until I reboot. (So now I have like 12 instances there.))
(I then changed my scanner code to start a new thread for loading each VST but it didn't change the behavior.)

Below are some tests I did with free VSTs, you can download the VSTs if you want to reproduce this:
http://www.fullbucket.de/music/kern.html (the version on vst4free is an older one.)
http://www.acoustica.com/plugins/vst-directx.htm or http://www.vst4free.com/free_vst.php?plugin=Classic_Auto-Filter&id=505 (not sure if it's the same version as in the installer. I used the installer)
http://www.yohng.com/software/piano.html
http://www.yohng.com/software/rpiano.html

All tests are done with the win32 version of these VSTs.
All of these VSTs have been tested with common DAWs like Ableton Live, Reaper and VSThost and they work.

This is the line referenced in the error output:
https://github.com/Earlz/rust-dylib/blob/master/src/lib.rs#L37

use std::path::Path;
use std::sync::{Arc, Mutex};
use std::error::Error;
use std::thread;

#[macro_use] extern crate vst2;
use vst2::plugin::{Info, Plugin, Category, HostCallback, CanDo};
use vst2::buffer::AudioBuffer;
use vst2::editor::{Editor, KeyCode, KnobMode};
use vst2::host::{Host, PluginLoader, PluginInstance};
use vst2::api::Supported;

struct SampleHost;

impl Host for SampleHost {}

fn main() {
    fn try_load_vst(path: &Path) -> Result<PluginInstance, Box<Error>> {
        let host = Arc::new(Mutex::new(SampleHost));
        Ok(try!(try!(PluginLoader::load(path, host.clone())).instance()))
    }
    fn print_info(path: &str) {
        let p = try_load_vst(&Path::new(path)).unwrap();
        println!("{:?}", p.get_info());
    }

    print_info(r"D:\VstPlugins\Full Bucket Music\kern.dll");
    /*
    output:
    thread '<main>' panicked at 'Error code 1411', D:\Program Files\.multirust\cargo\git\checkouts\rust-dylib-9df6a914a3be3341\master\src\lib.rs:37

    msvc debug output:
    'vstscan.exe' (Win32): Unloaded 'D:\VstPlugins\Full Bucket Music\kern.dll'
    Exception thrown at 0x773A5B68 (KernelBase.dll) in vstscan.exe: 0x00525354 (parameters: 0x00A76840, 0x00415C10).
    The thread 0x55a8 has exited with code 101 (0x65).
    The thread 0x44d0 has exited with code 101 (0x65).
    The program '[14816] vstscan.exe' has exited with code 101 (0x65).
    */

    print_info(r"D:\VstPlugins\Kjaerhus Classic\Classic Auto-Filter.dll");
    /*
    output:
    thread '<main>' panicked at 'Error code 1411', D:\Program Files\.multirust\cargo\git\checkouts\rust-dylib-9df6a914a3be3341\master\src\lib.rs:37

    stacktrace:
    thread '<main>' panicked at 'Error code 1411', D:\Program Files\.multirust\cargo
    \git\checkouts\rust-dylib-9df6a914a3be3341\master\src\lib.rs:37
    stack backtrace:
       0:   0xb36d8a - std::rt::lang_start::h61f4934e780b4dfc
       1:   0xb27e43 - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e2
    5
       2:   0xb28d80 - std::sys_common::unwind::begin_unwind_fmt::hb2de8a9968d38523
       3:   0x9c0705 - drop
                    at D:\projects\vstscan\src\<std macros>:8
       4:   0x9b79e5 - main
       5:   0x9b7ecd - load<vstscan::SampleHost>
                    at D:\projects\forks\rust-vst2\src\host.rs:317
       6:   0x9b564f - try_load_vst
                    at D:\projects\vstscan\src\main.rs:35
       7:   0x9b52e9 - print_info
                    at D:\projects\vstscan\src\main.rs:38
       8:   0x9b108e - main
                    at D:\projects\vstscan\src\main.rs:51
       9:   0xb366ed - std::rt::lang_start::h61f4934e780b4dfc
      10:   0xb364b2 - std::rt::lang_start::h61f4934e780b4dfc
      11:   0x9b5520 - main
      12: 0x77bf7c03 - BaseThreadInitThunk
      13: 0x77e4ad1e - RtlInitializeExceptionChain
    error: Process didn't exit successfully: `target\debug\vstscan.exe` (exit code: 101)

    msvc debug output:
    'vstscan.exe' (Win32): Unloaded 'D:\VstPlugins\Kjaerhus Classic\Classic Auto-Filter.dll'
    Exception thrown at 0x773A5B68 (KernelBase.dll) in vstscan.exe: 0x00525354 (parameters: 0x00850318, 0x01105C20).
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Cannot find or open the PDB file.
    The thread 0x49a4 has exited with code 101 (0x65).
    The program '[22052] vstscan.exe' has exited with code 101 (0x65).
    */

    // this next error only happens when both plugins are loaded in this order.
    // if you comment out a line the error doesn't happen.
    print_info(r"D:\VstPlugins\George Yohng\4Front Piano.dll");
    print_info(r"D:\VstPlugins\George Yohng\4Front R-Piano.dll");
    /*
    output:
     Running `target\debug\vstscan.exe`
    Info { name: "4Front Piano Module", vendor: "4Front", presets: 1, parameters: 0,
     inputs: 0, outputs: 2, unique_id: 877023310, version: 65792, category: Synth, i
    nitial_delay: 0, preset_chunks: true, f64_precision: false, silent_when_stopped:
     false }
    Info { name: "4Front R-Piano", vendor: "4Front Technologies", presets: 1, parame
    ters: 13, inputs: 0, outputs: 2, unique_id: 877019954, version: 131072, category
    : Synth, initial_delay: 0, preset_chunks: true, f64_precision: false, silent_whe
    n_stopped: false }
    thread '<main>' panicked at 'Error code 126', D:\Program Files\.multirust\cargo\
    git\checkouts\rust-dylib-9df6a914a3be3341\master\src\lib.rs:37
    stack backtrace:
       0:  0x13a6d0a - std::rt::lang_start::h61f4934e780b4dfc
       1:  0x1397e13 - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e2
    5
       2:  0x1398d60 - std::sys_common::unwind::begin_unwind_fmt::hb2de8a9968d38523
       3:  0x12304a5 - drop
                    at D:\projects\vstscan\src\<std macros>:8
       4:  0x1227735 - main
       5:  0x1227611 - drop_slow<dylib::DynamicLibrary>
                    at D:\projects\vstscan\src\liballoc\arc.rs:313
       6:  0x12275a4 - drop<dylib::DynamicLibrary>
                    at D:\projects\vstscan\src\liballoc\arc.rs:590
       7:  0x122746c - main
       8:  0x1227407 - main
       9:  0x12252a5 - print_info
                    at D:\projects\vstscan\src\main.rs:40
      10:  0x12210a5 - main
                    at D:\projects\vstscan\src\main.rs:97
      11:  0x13a666d - std::rt::lang_start::h61f4934e780b4dfc
      12:  0x13a6432 - std::rt::lang_start::h61f4934e780b4dfc
      13:  0x1225380 - main
      14: 0x77bf7c03 - BaseThreadInitThunk
      15: 0x77e4ad1e - RtlInitializeExceptionChain
    error: Process didn't exit successfully: `target\debug\vstscan.exe` (exit code:
    101)

    msvc debug output:
    'vstscan.exe' (Win32): Loaded 'D:\VstPlugins\George Yohng\4Front Piano.dll'. Module was built without symbols.
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Cannot find or open the PDB file.
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
    'vstscan.exe' (Win32): Unloaded 'D:\VstPlugins\George Yohng\4Front Piano.dll'
    'vstscan.exe' (Win32): Loaded 'D:\VstPlugins\George Yohng\4Front R-Piano.dll'. Module was built without symbols.
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\version.dll'. Cannot find or open the PDB file.
    'vstscan.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\version.dll'
    'vstscan.exe' (Win32): Unloaded 'D:\VstPlugins\George Yohng\4Front R-Piano.dll'
    Exception thrown at 0x773A5B68 (KernelBase.dll) in vstscan.exe: 0x00525354 (parameters: 0x009801F8, 0x013C5C60).
    'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Cannot find or open the PDB file.
    The thread 0x56f4 has exited with code 101 (0x65).
    The program '[22732] vstscan.exe' has exited with code 101 (0x65).
    */
}
@Boscop Boscop changed the title Strange errors when loading VSTs Strange errors when loading (win32) VSTs Jun 28, 2016
@Boscop
Copy link
Contributor Author

Boscop commented Jun 28, 2016

More tests, this time they occur after loading a couple other VSTs before:

http://www.vst4free.com/free_vst.php?id=1342
"D:\VstPlugins\Distorque\Azurite.dll"

msvc debug output:
Exception thrown at 0x6F5D346B (Azurite.dll) in vstscan.exe: 0xC0000005: Access violation reading location 0x70294700.

debugger shows this line as where it happens (again):
https://github.com/Earlz/rust-dylib/blob/master/src/lib.rs#L369


http://www.acustica-audio.com/index.php?option=com_virtuemart&page=shop.product_details&flypage=flypage.tpl&product_id=72&Itemid=53
"D:\VstPlugins\acustica\ACQUAVOX.dll"

msvc debug output:
Exception thrown at 0x10143CDB (ACQUAVOX.dll) in vstscan.exe: 0xC0000005: Access violation reading location 0x70294700.

crash in same line as above, after FreeLibrary()


Electri-Q (posihfopit edition)
http://www.pcjv.de/vst-plugins/eqs-filters/electri-q/

Exception thrown at 0x0055532D (Electri-Q (posihfopit edition).dll) in vstscan.exe: 0xC0000005: Access violation reading location 0x00000424.

msvc debugger points at this line:
https://github.com/overdrivenpotato/rust-vst2/blob/master/src/host.rs#L433


Tone2 Firebird
https://www.tone2.com/html/firebird%20vsti%20vst%20synthesizer%20plugin.html
"D:\VstPlugins\Firebird\FireBird.dll"

'vstscan.exe' (Win32): Loaded 'D:\VstPlugins\Firebird\FireBird.dll'. Module was built without symbols.
'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Cannot find or open the PDB file.
'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
'vstscan.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
Exception thrown at 0x100653CD (FireBird.dll) in vstscan.exe: 0xC0000005: Access violation writing location 0x00000000.

The program '[23456] vstscan.exe' has exited with code 0 (0x0).

msvc debugger points to:
https://github.com/Earlz/rust-dylib/blob/master/src/lib.rs#L311

@Boscop
Copy link
Contributor Author

Boscop commented Sep 3, 2016

Can anyone reproduce this behavior?
I'd also be interested in whether the scanner works on your system even if it's not windows :)

@overdrivenpotato
Copy link
Owner

overdrivenpotato commented Sep 4, 2016

So I tried testing this out with the plugins that have 64bit versions:

     Running `target\debug\examples\host2.exe`
loading kern.dll
Info { name: "Kern", vendor: "Bjoern Arlt @ Full Bucket Music", presets: 64, parameters: 32, inputs: 0, outputs: 2, unique_id: 1801810542, version: 1, category: Synth, initial_delay: 0, preset_chunks: false, f64_precision: true, silent_when_stopped: false }
loading 4Front Piano.dll
Info { name: "4Front Piano Module", vendor: "4Front", presets: 1, parameters: 0, inputs: 0, outputs: 2, unique_id: 877023310, version: 65792, category: Synth, initial_delay: 0, preset_chunks: true, f64_precision: false, silent_when_stopped: false }
loading 4Front R-Piano.dll
Info { name: "4Front R-Piano", vendor: "4Front Technologies", presets: 1, parameters: 13, inputs: 0, outputs: 2, unique_id: 877019954, version: 131072, category: Synth, initial_delay: 0, preset_chunks: true, f64_precision: false, silent_when_stopped: false }
loading Azurite.dll
Info { name: "Azurite", vendor: "Distorque", presets: 27, parameters: 19, inputs: 2, outputs: 2, unique_id: 1146175834, version: 1, category: Unknown, initial_delay: 0, preset_chunks: false, f64_precision: false, silent_when_stopped: false }
thread 'main' panicked at 'Error code 6', C:\Users\IEUser\.cargo\git\checkouts\rust-dylib-8d2b52a5c98ae95d\master\src\lib.rs:37
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Process didn't exit successfully: `target\debug\examples\host2.exe` (exit code: 101)

It seems that Azurite crashes upon unloading due to ERROR_INVALID_HANDLE. I'll do some testing on OSX but I'm not sure how to approach this issue, I'd like to avoid leaking plugins if possible.

EDIT: These tests were run with the default rustup install on Win10, perhaps the results differ with msvc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants