Skip to content

EventControllerKey.set_static_name SEGFAULT #2053

Closed
@otaxhu

Description

@otaxhu

Bug description

When I use the method EventControllerKey.set_static_name with a string literal param, then I add this controller to the window of the app, and then I open the GTK Inspector and visit the Controllers tab, I see one controller (I pressume it's the one I setted) with garbage characters (non-UTF-8), after navigating for a while, the application crashes with the Segmentation Fault (core dump) message.

I think it's because of the lifetime of the param not being 'static and the compiler optimizing it somehow.

fn set_static_name(name: Option<&str>) { ... }

Please provide a code sample as small as possible which reproduces the bug.

fn main() -> glib::ExitCode {
    let app: gtk::Application = glib::Object::builder().build();

    app.connect_activate(|app| {
        let window = gtk::ApplicationWindow::new(app);
        let key_controller = gtk::EventControllerKey::new();
        key_controller.set_static_name(Some("foo"));
        window.add_controller(key_controller);
        window.present()
    });

    app.run()
}

Backtrace

N/A because it doesn't panic, the process just get killed by the OS.

So the error is non-deterministic, I tried another run and the app didn't crash at any moment, but the garbage characters were still there

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions