Skip to content

AP_HAL_SITL: find dumpstack.sh when not run from the repo root - #34076

Open
peterbarker wants to merge 1 commit into
ArduPilot:masterfrom
peterbarker:pr-claude2/dumpstack-parallel-paths
Open

AP_HAL_SITL: find dumpstack.sh when not run from the repo root#34076
peterbarker wants to merge 1 commit into
ArduPilot:masterfrom
peterbarker:pr-claude2/dumpstack-parallel-paths

Conversation

@peterbarker

Copy link
Copy Markdown
Contributor

Summary

Use AP_SCRIPTS_DIR_PATH (if set) to find dumpstack and dumpcore

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest) (when things go bad under parallel testing)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

run_command_on_ownpid() looks for dumpstack.sh and dumpcore.sh relative to the working directory. A serial autotest run works because it runs in the repo root, but under --parallel each instance runs in its own directory, every lookup misses, and we fall back to trusting PATH - where the script is not. A panic there produced "Failed" and no backtrace at all, which is precisely when one is wanted.

The AP_SCRIPTS_DIR_PATH override already existed, but the filepath was formed into a 60-byte buffer. An absolute path to a checkout overflows that easily - /home/user/rc/ardupilot-claude2/Tools/scripts/dumpstack.sh is 61 characters - and snprintf simply truncated, leaving a name which failed to stat, so the override looked as though it had been ignored.

Size the buffer for a path, and skip any candidate which does not fit rather than stat'ing a truncated name.

run_command_on_ownpid() looks for dumpstack.sh and dumpcore.sh relative
to the working directory.  A serial autotest run works because it runs
in the repo root, but under --parallel each instance runs in its own
directory, every lookup misses, and we fall back to trusting PATH -
where the script is not.  A panic there produced "Failed" and no
backtrace at all, which is precisely when one is wanted.

The AP_SCRIPTS_DIR_PATH override already existed, but the filepath was
formed into a 60-byte buffer.  An absolute path to a checkout overflows
that easily - /home/user/rc/ardupilot-claude2/Tools/scripts/dumpstack.sh
is 61 characters - and snprintf simply truncated, leaving a name which
failed to stat, so the override looked as though it had been ignored.

Size the buffer for a path, and skip any candidate which does not fit
rather than stat'ing a truncated name.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant