GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix crash on NaN DDC value after display reconfiguration by Bouke · Pull Request #1932 · MonitorControl/MonitorControl

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@waydabber

waydabber commented Nov 1, 2026

Copy link
Copy Markdown
Member

Thanks for the fix! The ordering change and NaN cleanup look good.

One small edge case: with minDDCOverride = 100 and a reported max of 80, the fallback sets maxDDC to 100 too. This still causes division by zero and saves NaN again. Could you make sure the final effective max is always greater than the min before converting?

Once this is fixed, I'll merge it. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Bouke
Store maxDDC before converting the read DDC value
79d5e25
On first setup (or when the effective maximum isn't above the minimum, such as a display reporting 0) the read value was converted with min == max, 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.
@Bouke

Bouke commented Nov 2, 2026

Copy link
Copy Markdown
Author

Good catch; any min override of 100 or more ended up there, as the detect limit also clips the reported max. The effective max is now forced above the min before saving.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Bouke
Bouke force-pushed the fix/nan-ddc-value-crash branch from 9906864 to 79d5e25 Compare November 6, 2026 14:47
@Bouke

Bouke commented Nov 6, 2026

Copy link
Copy Markdown
Author

Sorry, forgot to push my changes!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Bouke @waydabber
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.