Assertion 'PANGO_IS_LAYOUT (layout)' failed with GTK Entry

I’m currently building my first GTK app in Rust and it’s been great so far but I’ve run into a problem. I have a gtk::Entry pre-populated with text being presented in a gtk::Window modal. But when it launches if I hit the left or right arrow key it will usually (but not always) crash with the following error:

Pango-CRITICAL **: 18:36:30.302: _pango_layout_get_iter: assertion ‘PANGO_IS_LAYOUT (layout)’ failed

The odd thing is that if the gtk::Entry is not pre-populated with text the crash won’t happen.

I’ve extracted out the minimal code to reproduce this below:

use gtk::glib;
use gtk::prelude::*;

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

    app.connect_activate(|app| {
        let window = gtk::ApplicationWindow::new(app);
        let modal = gtk::Window::builder()
        let text = "Hello there!";
        let entry = gtk::Entry::builder().text(text).build();
        let child = gtk::Box::new(gtk::Orientation::Vertical, 0);


And here’s my Cargo file:

name = "gtk-pango-is-layout-error"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at

gtk = { version = "0.6.1", package = "gtk4", features = ["v4_6"] }

Anyone have any idea what could be causing this or how to debug it?

EDIT: I’ve found a workaround for this by inserting the following code in the app.connect_activate callback.

if let Some(settings) = gtk::Settings::default() {

This deselects the entry text initially which appears to mitigate the crashing issue but I would prefer to resolve this issue without having to utilize a hack like this.

1 Like

Hi @jbenner! The next step would be to capture a stacktrace in GDB. I’ll try compiling your sample code later today

Thanks @lb90 ! I’ll look into GDB and see what I can come up with.