Visitar URL original
Fix crash on NaN DDC value after display reconfiguration by Bouke · Pull Request #1932 · MonitorControl/MonitorControl · GitHub
Skip to content

Fix crash on NaN DDC value after display reconfiguration - #1932

Open
Bouke wants to merge 1 commit into
MonitorControl:mainfrom
Bouke:fix/nan-ddc-value-crash
Open

Bouke wants to merge 1 commit into
MonitorControl:mainfrom
Bouke:fix/nan-ddc-value-crash

Conversation

@Bouke

@Bouke Bouke commented Oct 27, 2026

Copy link
Copy Markdown

When a display shows up under a new prefs id (after wake or re-docking, for example), setupCurrentAndMaxValues converts the DDC value it just read before maxDDC is stored. With min and max both 0, convDDCToValue divides 0 by 0 and the NaN gets saved as the current value. The next brightness change then traps on UInt16(NaN) in convValueToDDC; the min/max clamps don't help, as they pass NaN through.

This PR stores maxDDC before converting the read value. A display that reports a maximum of 0 falls back to DDC_MAX_DETECT_LIMIT (I've seen an iiyama do this for volume over HDMI), and a NaN that earlier versions already saved is removed, so the value is read again.

I reproduced it on 4.4.0 by removing the maxDDC keys from the prefs: every command logged Current internal value: nan and the next brightness key press crashed. With this change the same steps give valid values. Probably the same crash as #1919. #1874 also guards against min == max in the conversions, but doesn't cover the ordering or the NaN values already in people's prefs.

On first setup (or when a display reports a maximum of 0) the read value was converted using a maxDDC of 0, saving NaN to the prefs. Converting that back to a DDC value traps, crashing the app on the next brightness change.

Existing NaN prefs are removed on setup, so affected users recover without resetting their settings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant