slint icon indicating copy to clipboard operation
slint copied to clipboard

debug_assert hit during debug builds gives no indication of where issue is

Open flukejones opened this issue 1 year ago • 3 comments

I hit this last night, the i_slint_compiler::passes::default_geometry::fix_percent_size gave me a hint of what the issue might be, but not where. I essentially had to grep on my codebase and comment various points where a percentage was specified for layouting. I wonder if there might be some additional message that could be provided?

error: failed to run custom build command for `rog-control-center v6.0.7 (/home/luke/Projects/asus-linux/asusctl/rog-control-center)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/home/luke/Projects/asus-linux/asusctl/target/debug/build/rog-control-center-88dbcc5d076bd4e7/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at /home/luke/.cargo/git/checkouts/slint-8153123e5dffa129/7b3e2fcf32d2/internal/compiler/passes/default_geometry.rs:281:9:
  assertion `left == right` failed
    left: Invalid
   right: LogicalLength
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
     1: core::panicking::panic_fmt
               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
     2: core::panicking::assert_failed_inner
               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:343:17
     3: core::panicking::assert_failed
     4: i_slint_compiler::passes::default_geometry::fix_percent_size
     5: i_slint_compiler::object_tree::recurse_elem
     6: i_slint_compiler::object_tree::recurse_elem_including_sub_components
     7: i_slint_compiler::object_tree::recurse_elem
     8: i_slint_compiler::object_tree::recurse_elem
     9: i_slint_compiler::object_tree::recurse_elem
    10: i_slint_compiler::object_tree::recurse_elem
    11: i_slint_compiler::object_tree::recurse_elem
    12: i_slint_compiler::object_tree::recurse_elem
    13: i_slint_compiler::object_tree::recurse_elem
    14: i_slint_compiler::object_tree::recurse_elem
    15: i_slint_compiler::object_tree::recurse_elem_including_sub_components
    16: i_slint_compiler::passes::default_geometry::default_geometry
    17: i_slint_compiler::passes::run_passes::{{closure}}
    18: i_slint_compiler::compile_syntax_node::{{closure}}
    19: spin_on::spin_on
    20: slint_build::compile_with_config
    21: build_script_build::main
    22: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...

https://github.com/slint-ui/slint/blob/7b3e2fcf32d2937a8ed58bcc742e45dd4852bced/internal/compiler/passes/default_geometry.rs#L281

flukejones avatar May 13 '24 20:05 flukejones

Thanks for the bug report. This is clearly a case of "should not happen" :). This would happen if you're using either width: 10%;" or height: 10%" (or some other number, just with a percent suffix) and the parent element would declare a width or height property that's not a (logical) length. However before hitting this, there should be an error about the inability to declare a "width" or "height" property in the first place (since those are reserved).

Do you know anything about the surrounding code that triggers this?

tronical avatar May 14 '24 07:05 tronical

Would it be possible to get a reproducible example?

ogoffart avatar May 28 '24 15:05 ogoffart

Unfortunately not from my side. I went quite far with work after this point and don't recall which commit it was in my project.

flukejones avatar Jun 02 '24 06:06 flukejones

I believe I have reproduced this, the error is being thrown by this debug_assert_eq.

Steps to reproduce:

  • Wrap an Text element in a ScrollView
  • Set the Texts width to 100%
  • Build with debug

Example

    ScrollView {
        Text {
            width: 100%;
        }
    }

Workaround, don't use a percentage, use width: 0.3 * parent.width; or build with release.

If there is anything else I could do to help let me know, thanks!

ChaseCares avatar Jul 04 '24 11:07 ChaseCares

Thanks @ChaseCares This is actually a duplicate of #4163 so i'm going to close it as such.

There is actually a fix for it in https://github.com/slint-ui/slint/pull/4223 but it hasn't been merged yet

ogoffart avatar Sep 11 '24 15:09 ogoffart