Skip to content

fix(llf): harden inputs across particle lights#88

Merged
alandtse merged 2 commits into
devfrom
fix/minor-input-hardening
Jun 4, 2026
Merged

fix(llf): harden inputs across particle lights#88
alandtse merged 2 commits into
devfrom
fix/minor-input-hardening

Conversation

@alandtse
Copy link
Copy Markdown
Owner

@alandtse alandtse commented Jun 3, 2026

Summary

Addresses the four minor hardening items tracked in #87 — pre-existing issues surfaced by CodeRabbit during #56's review, in files outside that PR's scope, so split out here.

Fix File Problem
Div-by-zero guard LightLimitFix/Particle.cpp lightFadeEnd == lightFadeStart (non-zero) made the dimmer interpolation divide by zero → NaN/Inf into lighting. Now lightFadeEnd <= lightFadeStart takes the full-brightness branch.
Deterministic dedupe LightLimitFix/ParticleLights.cpp get_configs order is filesystem-dependent; the "first wins" duplicate policy could pick different winners across installs. std::sort before both loops (ParticleLights + Gradients).
Hex-width validation LightLimitFix/ParticleLights.cpp Gradient color validated charset but not length, so #1 / #12345 packed as garbage 32-bit colors. Now requires exactly 6 (RRGGBB) or 8 (AARRGGBB) digits — fails closed.
Clamp stored value Upscaling.cpp Only the UI index was clamped; a stale/hand-edited streamlineLogLevel persisted unclamped through save/restart-diff. Now the stored value itself is clamped.

All four verified present on dev before fixing; each is the change CodeRabbit suggested, kept minimal.

Validation

⚠️ Not built locally — the local C: drive is full (~20 MB free), which blocks MSVC's temp compilation; the build drive (F:) is fine. The changes are minimal and self-contained (a conditional guard, two std::sort calls with <algorithm> already included, a size() check, and a std::min clamp on a uint), so I'm relying on CI's full build + cpp_tests + shader validation here.

Closes #87.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 3, 2026 05:47
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@alandtse, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 29 minutes and 18 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0031a923-e695-4942-b252-4754a322c83f

📥 Commits

Reviewing files that changed from the base of the PR and between a47f46b and 70348b2.

📒 Files selected for processing (3)
  • src/Features/LightLimitFix/Particle.cpp
  • src/Features/LightLimitFix/ParticleLights.cpp
  • src/Features/Upscaling.cpp
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/minor-input-hardening

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

No actionable suggestions for changed features.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens configuration and engine-input handling in LightLimitFix particle lights and Upscaling, addressing minor robustness issues (division-by-zero avoidance, deterministic config ordering, stricter hex validation, and sanitization of persisted settings).

Changes:

  • Guarded particle-light fade interpolation against degenerate lightFadeEnd <= lightFadeStart to prevent divide-by-zero/NaN propagation.
  • Sorted particle-light config file lists to make duplicate “first wins” behavior deterministic across filesystem iteration orders.
  • Tightened gradient color parsing to require exactly 6 or 8 hex digits, and clamped streamlineLogLevel prior to using it as a UI index.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Features/Upscaling.cpp Clamps persisted Streamline log level before UI use to avoid out-of-range indexing/persistence issues.
src/Features/LightLimitFix/ParticleLights.cpp Sorts config lists for determinism and strengthens gradient hex-width validation.
src/Features/LightLimitFix/Particle.cpp Adds a fade-range degeneracy guard to prevent divide-by-zero in dimmer interpolation.

Comment thread src/Features/LightLimitFix/ParticleLights.cpp Outdated
Comment thread src/Features/Upscaling.cpp Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse force-pushed the fix/minor-input-hardening branch from 4a34adf to 8482cbb Compare June 3, 2026 07:13
Copilot AI review requested due to automatic review settings June 3, 2026 09:20
@alandtse alandtse force-pushed the fix/minor-input-hardening branch from 8482cbb to f45f94c Compare June 3, 2026 09:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread src/Features/Upscaling.cpp Outdated
alandtse and others added 2 commits June 3, 2026 10:24
Addresses the minor hardening items in #87 (pre-existing, surfaced by
CodeRabbit on #56):

- Particle.cpp: guard the dimmer interpolation against lightFadeEnd <=
  lightFadeStart so equal engine fade globals can't divide by zero
  (NaN/Inf into GPU lighting).
- ParticleLights.cpp: std::sort the get_configs results before the
  'first wins' duplicate dedupe so the surviving config is deterministic
  across installs (both ParticleLights and Gradients loops).
- ParticleLights.cpp: require exactly 6 or 8 hex digits for gradient
  colors so malformed widths (#1, #12345) fail closed instead of packing
  a garbage 32-bit color.
- Upscaling.cpp: clamp the stored streamlineLogLevel (not just the UI
  index) so a stale/hand-edited out-of-range value can't persist through
  the save / restart-diff paths.

Closes #87
- ParticleLights: validate hex digits with bounded find_first_not_of
  instead of strspn on string_view::data(), which is not guaranteed to
  be NUL-terminated.
- Upscaling: clamp streamlineLogLevel in LoadSettings so a stale or
  out-of-range JSON value is sanitized on every load, not only when the
  Backend Diagnostics tree node is expanded. Drop the now-redundant
  in-tree clamp whose comment claimed coverage it did not provide.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 3, 2026 10:24
@alandtse alandtse force-pushed the fix/minor-input-hardening branch from c9b2962 to 70348b2 Compare June 3, 2026 10:24
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@alandtse alandtse changed the title fix(llf): harden degenerate/malformed inputs across particle lights fix(llf): harden inputs across particle lights Jun 4, 2026
@alandtse alandtse merged commit 883c3c2 into dev Jun 4, 2026
20 checks passed
ParticleTroned added a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request Jun 4, 2026
Avoid degenerate particle-light fade interpolation, make duplicate config selection deterministic, and reject malformed gradient color widths with bounded string_view validation.

The upscaling streamlineLogLevel part of alandtse#88 is intentionally skipped because this branch already sanitizes the stored setting during LoadSettings.

Co-authored-by: alandtse <7086117+alandtse@users.noreply.github.com>
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.

Minor hardening: particle-light div-by-zero, config determinism, hex/log-level validation

2 participants