Skip to content

fix(amd-topo): guard non-numeric byte counts in amd_memory_type - #6323

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/amd-topo-non-numeric-bytes
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/amd-topo-non-numeric-bytes

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/installers/lib/amd-topo.sh, amd_memory_type() classifies whether an AMD GPU topology exhibits discrete or unified memory by performing integer division in Bash arithmetic ($(( gtt_bytes / 1073741824 )) and $(( vram_bytes / 1073741824 ))). When topology discovery encounters missing sysfs entries, unpopulated driver nodes, or placeholder text such as "N/A", Bash under set -euo pipefail halts with unbound variable or arithmetic syntax errors, terminating multi-GPU topology discovery before fallbacks can be evaluated.

This patch adds surgical regex guards [[ "$vram_bytes" =~ ^[0-9]+$ ]] || vram_bytes=0 and [[ "$gtt_bytes" =~ ^[0-9]+$ ]] || gtt_bytes=0 in amd_memory_type(). Any non-numeric or missing input safely defaults to 0 bytes and cleanly falls back to "discrete". Existing APU threshold logic and valid topology detection remain untouched.

Validation

  • Baseline: Invoking amd_memory_type "invalid" "N/A" failed with line 50: N: unbound variable and non-zero exit code.
  • Post-fix: Non-numeric and empty inputs cleanly return discrete with exit code 0; valid discrete and unified byte counts continue to evaluate correctly.
  • AMD topology detection suites: 4 passed. New-test Ruff, ShellCheck, and diff checks pass; new regressions wired into Linux CI.

Overlap check

Risk / AI disclosure

AI-assisted investigation, implementation and CLI regressions. This strengthens a shell arithmetic input guard, not runtime admission. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.

Follow-up integration evidence

Composed with #6076 at 5662f0d without conflicts. Production and test diffs passed together; AMD topology classification checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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.

2 participants