Skip to content

Panic on Unwrap in sharedparley::layout #10336

@qarmin

Description

@qarmin

Feature Description

Recently, one of the users who was running the application inside a VM reported a panic in my app.

18:26:27.495 [INFO] czkawka_core::common::logger: Logging to file "/home/yanganto/.cache/czkawka/krokiet.log" and terminal
18:26:27.499 [INFO] czkawka_core::common::logger: Krokiet version: 10.0.0(<unknown> U <unknown>), release mode, rust 1.90.0 (2025-09-14), os NixOS 25.11.0 (x86_64 64-bit), 32 cpu/threads, features(0): [], app cpu version: x86-64-v1 (SSE2), os cpu version: x86-64-v4 (AVX-512), libc glibc [build + runtime (glibc 2.40 | musl <not detected>)]
18:26:27.499 [INFO] czkawka_core::common::config_cache_path: Config folder set to "/home/yanganto/.config/krokiet" and cache folder set to "/home/yanganto/.cache/czkawka"
18:26:27.499 [INFO] krokiet: Krokiet features(2): [winit_femtovg, winit_software]
18:26:27.609 [ERROR] log_panics: thread 'main' panicked at 'called `Option::unwrap()` on a `None` value': /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/i-slint-core-1.14.1/textlayout/sharedparley.rs:229
   0: log_panics::Config::install_panic_hook::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::begin_panic_handler::{{closure}}
   3: std::sys::backtrace::__rust_end_short_backtrace
   4: __rustc::rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::panicking::panic
   7: core::option::unwrap_failed
   8: i_slint_core::textlayout::sharedparley::layout
   9: i_slint_core::textlayout::sharedparley::draw_text
  10: <i_slint_renderer_femtovg::itemrenderer::GLItemRenderer<R> as i_slint_core::item_rendering::ItemRenderer>::draw_text
  11: i_slint_core::items::ComplexTextVTable::render
  12: i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item
  13: i_slint_core::item_tree::visit_item_tree

So the crash clearly happened in the text layouting code path. When looking at the source:

let item = line.items().next().unwrap();

there is a plain, unconditional unwrap without any explanation why this cannot panic, instead of proper error handling.

This is not the first time I’ve seen random panics in Slint, so I think the entire repository (except maybe auto-generated code) should use the following clippy flag:

#![warn(clippy::unwrap_used)]

and replace all unwrap calls with proper error handling or expect calls that include a meaningful message, which would help with diagnosing the root cause of such errors.

Product Impact

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:textText rendering, fonts, Text input (mS,bF)need triagingIssue that the owner of the area still need to triage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions