{"record":{"id":"021c30d503498d1d","repo":"linebender/druid","slug":"got-nonsensical-mode-values","errorCode":null,"errorMessage":"got nonsensical mode values","messagePattern":"got nonsensical mode values","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"druid-shell/src/backend/x11/util.rs","lineNumber":45,"sourceCode":"            .first()\n            .ok_or_else(|| anyhow!(\"didn't get any modes\"))\n            .and_then(|mode_info| {\n                let flags = mode_info.mode_flags;\n                let vtotal = {\n                    let mut val = mode_info.vtotal;\n                    if (flags & u32::from(ModeFlag::DOUBLE_SCAN)) != 0 {\n                        val *= 2;\n                    }\n                    if (flags & u32::from(ModeFlag::INTERLACE)) != 0 {\n                        val /= 2;\n                    }\n                    val\n                };\n\n                if vtotal != 0 && mode_info.htotal != 0 {\n                    Ok((mode_info.dot_clock as f64) / (vtotal as f64 * mode_info.htotal as f64))\n                } else {\n                    Err(anyhow!(\"got nonsensical mode values\"))\n                }\n            })\n    };\n\n    match try_refresh_rate() {\n        Err(e) => {\n            tracing::error!(\"failed to find refresh rate: {}\", e);\n            None\n        }\n        Ok(r) => Some(r),\n    }\n}\n\n// Apparently you have to get the visualtype this way :|\nfn find_visual_from_screen(screen: &Screen, visual_id: u32) -> Option<Visualtype> {\n    for depth in &screen.allowed_depths {\n        for visual in &depth.visuals {\n            if visual.visual_id == visual_id {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/x11/util.rs#L27-L63","documentation":"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.","triggerScenarios":"Thrown at druid-shell/src/backend/x11/util.rs:45 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Skip the offending mode and use another mode from the list to compute the refresh rate","Fall back to a default refresh rate (e.g. 60 Hz) when timings are invalid","Clamp htotal/vtotal values before dividing to avoid division by zero"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0f8b1195e4e073f9597f2865299c3d18f8e4005f","analyzedAt":"2026-09-10T14:27:34.582Z","contentChangedAt":"2026-09-10T14:27:34.582Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}