Skip to content

Segfault when opening (and closing) the controller more than once #1500

@zohnannor

Description

@zohnannor

If I run this code:

fn main() {
    let sdl2 = sdl2::init().unwrap();
    let gcs = sdl2.game_controller().unwrap();

    let gamepad = gcs.open(0).unwrap();
    drop(gamepad); // <--------
    let gamepad = gcs.open(0).unwrap();
    drop(gamepad);
    drop(gcs);
    drop(sdl2);
}
Segmentation fault

If I remove marked line (drop for the first instance of 0th gamepad), then Segmentation fault doesn't happen.

To be completely honest, I have no idea how that prevents the segfault.


Cargo.toml:

sdl2 = { version = "0.38.0", features = ["bundled", "hidapi", "static-link"] }

OS: Windows 10
shell: Git Bash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions