linebender/druid · error

got nonsensical mode values

Error message

got nonsensical mode values

What it means

Validation error in refresh_rate (x11 util): after adjusting the XRandR mode's vtotal for DOUBLE_SCAN (×2) or INTERLACE (÷2), the computed values produce a nonsensical refresh rate — e.g. a zero or negative denominator/numerator when dividing htotal/vtotal. It fires for malformed or degenerate mode timing data reported by XRandR, and the mode is rejected via anyhow.

Solutions

  1. Skip the offending mode and use another mode from the list to compute the refresh rate
  2. Fall back to a default refresh rate (e.g. 60 Hz) when timings are invalid
  3. Clamp htotal/vtotal values before dividing to avoid division by zero
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at druid-shell/src/backend/x11/util.rs:45 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of linebender/druid@0f8b1195e4 (2026-09-10). Data as JSON: /api/errors/021c30d503498d1d. Report an issue: GitHub.

Appendix: source

Thrown at druid-shell/src/backend/x11/util.rs:45

            .first()
            .ok_or_else(|| anyhow!("didn't get any modes"))
            .and_then(|mode_info| {
                let flags = mode_info.mode_flags;
                let vtotal = {
                    let mut val = mode_info.vtotal;
                    if (flags & u32::from(ModeFlag::DOUBLE_SCAN)) != 0 {
                        val *= 2;
                    }
                    if (flags & u32::from(ModeFlag::INTERLACE)) != 0 {
                        val /= 2;
                    }
                    val
                };

                if vtotal != 0 && mode_info.htotal != 0 {
                    Ok((mode_info.dot_clock as f64) / (vtotal as f64 * mode_info.htotal as f64))
                } else {
                    Err(anyhow!("got nonsensical mode values"))
                }
            })
    };

    match try_refresh_rate() {
        Err(e) => {
            tracing::error!("failed to find refresh rate: {}", e);
            None
        }
        Ok(r) => Some(r),
    }
}

// Apparently you have to get the visualtype this way :|
fn find_visual_from_screen(screen: &Screen, visual_id: u32) -> Option<Visualtype> {
    for depth in &screen.allowed_depths {
        for visual in &depth.visuals {
            if visual.visual_id == visual_id {

View on GitHub (pinned to 0f8b1195e4)