garkimasera / vlc-rs

Rust bindings for libVLC media framework.
MIT License
67 stars 19 forks source link

HEAP Corruption on running from powershell but no such thing on ucrt64 #17

Open Dr-42 opened 1 year ago

Dr-42 commented 1 year ago

I have rust gnu toolchain installed and I am using msys2 for environment setup. I installed UCRT64 vlc using pacman and am using rust package from msys2.

When I launch the program from powershell I get error

error: process didn't exit successfully: `target\debug\offnet.exe` (exit code: 0xc0000374, STATUS_HEAP_CORRUPTION)

but launching cargo run from ucrt64 shell works fine. On debugging the heap corruption seems to occuring on VLC::CreateNewInstance

Source code to reproduce

extern crate glfw;

use glfw::{Action, Context, Key};
extern crate vlc;
use vlc::{Instance, Media, MediaPlayer};

fn main() {
    let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

    let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
        .expect("Failed to create GLFW window.");

    window.set_key_polling(true);
    window.make_current();
    /*let win_hnd = match win_handle {
        RawWindowHandle::Win32(handle) => handle,
        _ => panic!("Not supported")
    };*/
    let win_hnd = window.get_win32_window();

    let instance = Instance::new().unwrap();
    // Create a media from a file
    let md = Media::new_path(&instance, "tst.mp4").unwrap();
    // Create a media player
    let mdp = MediaPlayer::new(&instance).unwrap();
    mdp.set_hwnd(win_hnd);
    mdp.set_media(&md);

    mdp.play().unwrap();
    while !window.should_close() {
        glfw.poll_events();
        for (_, event) in glfw::flush_messages(&events) {
            handle_window_event(&mut window, event);
        }
    }
}

fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
    match event {
        glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
            window.set_should_close(true)
        }
        _ => {}
    }
}

I also have all the folders added to environement path that appear on running echo $PATH in ucrt64 shell I am using the glfw crate to create the window.