Arm backend: fix unbound ARM_SETUP_CURL_PROGRESS_ARGS under bash 3.2 - #22337
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22337
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 1 Unrelated Failure, 1 Unclassified FailureAs of commit cbb80d1 with merge base d614f9d ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @synath! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
|
|
|
|
@pytorchbot label "release notes: arm" |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
ARM_SETUP_CURL_PROGRESS_ARGS is only assigned when detect_ci.sh reports a
CI environment; on a local run it stays unset, and setup.sh runs under
set -u. Bash releases before 4.4 treat "${arr[@]}" as an unbound-variable
error when the array is unset -- and also when it is empty, so
initializing the array to () would still crash macOS's stock bash 3.2.
Guard the three expansion sites with the portable ${arr[@]+...} idiom,
which expands to nothing when the array is unset or empty and preserves
each element's quoting otherwise.
Verified on macOS stock bash 3.2.57 (set -u): the old form errors for
both unset and empty arrays; the guarded form succeeds for unset, empty,
and populated (CI) states and passes the CI flag through unchanged.
Fixes pytorch#22313
248c409 to
cbb80d1
Compare
|
/easycla |
|
Wow good catch! Thanks for you contribution, I kicked of the GitHub testing :) |
|
OK to merge, let me know if you have problem and I can press the button for you. I'm not 100% sure who have permissions to merge/submit :) |
|
Thanks @zingo! Looks like I don't have merge permissions (or the failing CI jobs prevent it? I thought I saw a merge button at some point before CI ran, but there isn't one now), so please go ahead. The CI failures appear unrelated to this minor change. Thanks for letting me pitch in! |
Summary
Fixes #22313
examples/arm/setup.shruns underset -u, butARM_SETUP_CURL_PROGRESS_ARGSis only assigned when
.ci/scripts/detect_ci.shdetects a CI environment. On alocal run the array is never set, and the first download aborts on macOS's
stock bash:
CI never sees this because bash >= 4.4 expands an unset array under
set -uwithout error; macOS ships bash 3.2.57.
This PR guards the three expansion sites (
utils.sh:download_with_retry, andthe two
curlcalls invulkan_utils.sh) with the portable idiom:${ARM_SETUP_CURL_PROGRESS_ARGS[@]+"${ARM_SETUP_CURL_PROGRESS_ARGS[@]}"}Why not just initialize the array to
()near the top ofsetup.sh: bashbefore 4.4 raises the same error when expanding an empty array under
set -u, so that would still crash on macOS. The+parameter-expansionguard handles unset and empty alike, and preserves per-element quoting when
the array is populated (the CI case).
Test plan
Manual, on macOS 26 / stock
/bin/bash3.2.57. Reproduce each state of thearray against both the old and the guarded expansion (
printfstanding infor
curl):Also verified: identical guarded-form behavior on bash 5.3 (no regression for
Linux/CI), and
bash -nsyntax checks pass on both edited scripts under bothbash versions.
Developed with Claude's assistance (co-author trailer on the commit); diagnosed
on my machine while working through the Ethos-U getting-started tutorial, and
verified by me on macOS 26 / stock bash 3.2.57.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani