Skip to content

Arm backend: fix unbound ARM_SETUP_CURL_PROGRESS_ARGS under bash 3.2 - #22337

Merged
rascani merged 1 commit into
pytorch:mainfrom
synath:fix-arm-setup-curl-args-bash32
Aug 31, 2026
Merged

Arm backend: fix unbound ARM_SETUP_CURL_PROGRESS_ARGS under bash 3.2#22337
rascani merged 1 commit into
pytorch:mainfrom
synath:fix-arm-setup-curl-args-bash32

Conversation

@synath

@synath synath commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #22313

examples/arm/setup.sh runs under set -u, but ARM_SETUP_CURL_PROGRESS_ARGS
is only assigned when .ci/scripts/detect_ci.sh detects a CI environment. On a
local run the array is never set, and the first download aborts on macOS's
stock bash:

backends/arm/scripts/utils.sh: line 96: ARM_SETUP_CURL_PROGRESS_ARGS[@]: unbound variable

CI never sees this because bash >= 4.4 expands an unset array under set -u
without error; macOS ships bash 3.2.57.

This PR guards the three expansion sites (utils.sh:download_with_retry, and
the two curl calls in vulkan_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 of setup.sh: bash
before 4.4 raises the same error when expanding an empty array under
set -u, so that would still crash on macOS. The + parameter-expansion
guard 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/bash 3.2.57. Reproduce each state of the
array against both the old and the guarded expansion (printf standing in
for curl):

# old form — errors when unset, errors when empty, OK when set:
/bin/bash -uc 'printf "<%s>" x "${A[@]}" y'                  # error: A[@]: unbound variable
/bin/bash -uc 'A=(); printf "<%s>" x "${A[@]}" y'            # error: A[@]: unbound variable
/bin/bash -uc 'A=(--no-progress-meter); printf "<%s>" x "${A[@]}" y'   # <x><--no-progress-meter><y>

# guarded form — OK in all three states, quoting preserved:
/bin/bash -uc 'printf "<%s>" x ${A[@]+"${A[@]}"} y'          # <x><y>
/bin/bash -uc 'A=(); printf "<%s>" x ${A[@]+"${A[@]}"} y'    # <x><y>
/bin/bash -uc 'A=(--no-progress-meter); printf "<%s>" x ${A[@]+"${A[@]}"} y'   # <x><--no-progress-meter><y>

Also verified: identical guarded-form behavior on bash 5.3 (no regression for
Linux/CI), and bash -n syntax checks pass on both edited scripts under both
bash 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

@pytorch-bot

pytorch-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

🔗 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 Failure

As of commit cbb80d1 with merge base d614f9d (image):

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.

@meta-cla

meta-cla Bot commented Aug 30, 2026

Copy link
Copy Markdown

Hi @synath!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 30, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: synath / name: David Turley (cbb80d1)

@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Aug 30, 2026
@pytorch-bot

pytorch-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@synath

synath commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "release notes: arm"

@pytorch-bot pytorch-bot Bot added the release notes: arm Changes to the ARM backend delegate label Aug 30, 2026
@meta-cla

meta-cla Bot commented Aug 30, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 30, 2026
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
@synath
synath force-pushed the fix-arm-setup-curl-args-bash32 branch from 248c409 to cbb80d1 Compare August 30, 2026 22:44
@synath

synath commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

/easycla

@synath
synath marked this pull request as ready for review August 30, 2026 23:02
@synath
synath requested a review from digantdesai as a code owner August 30, 2026 23:02
@zingo zingo added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label Aug 31, 2026
@zingo

zingo commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Wow good catch! Thanks for you contribution, I kicked of the GitHub testing :)

@zingo

zingo commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

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 :)

@synath

synath commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

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!

@rascani
rascani merged commit fba44cc into pytorch:main Aug 31, 2026
510 of 517 checks passed
@synath
synath deleted the fix-arm-setup-curl-args-bash32 branch August 31, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: arm Changes to the ARM backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arm backend: setup.sh crashes on macOS stock bash 3.2 (ARM_SETUP_CURL_PROGRESS_ARGS[@]: unbound variable)

4 participants