Skip to content

fix(walltime): use brew-installed bash for samply on macOS#347

Merged
not-matthias merged 2 commits into
mainfrom
cod-2649-fix-samply-crashing-due-to-signed-bash
May 13, 2026
Merged

fix(walltime): use brew-installed bash for samply on macOS#347
not-matthias merged 2 commits into
mainfrom
cod-2649-fix-samply-crashing-due-to-signed-bash

Conversation

@not-matthias
Copy link
Copy Markdown
Member

@not-matthias not-matthias commented May 13, 2026

samply currently crashes on macOS because it ends up profiling the system's signed /bin/bash. SIP blocks the instrumentation samply needs (e.g. DYLD_INSERT_LIBRARIES), and anything launched through that bash — including Python — inherits the same restriction. We need an unsigned bash earlier on PATH for the samply child process.

Fixes COD-2649

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 13, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 7 untouched benchmarks


Comparing cod-2649-fix-samply-crashing-due-to-signed-bash (e26d369) with main (fa0bfcb)

Open in CodSpeed

Repository was transferred from AvalancheHQ/samply to
CodSpeedHQ/samply-codspeed. Same commit, same branch.
@not-matthias not-matthias force-pushed the cod-2649-fix-samply-crashing-due-to-signed-bash branch 2 times, most recently from e5cc90c to b3c84c5 Compare May 13, 2026 02:10
Copy link
Copy Markdown
Contributor

@GuillaumeLagrange GuillaumeLagrange left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread src/executor/helpers/command.rs Outdated
Comment thread src/executor/helpers/homebrew.rs Outdated
samply can't profile macOS's Apple-signed /bin/bash (and Python launched
through it), so it needs an unsigned (ad-hoc-signed) bash. On macOS we now:

- Probe the `bash` first on PATH with `codesign -dv` and only intervene
  when it lacks `Signature=adhoc` (i.e. system bash or another signed
  build). If a compatible bash is already on PATH (e.g. Homebrew's), we
  skip the brew dance entirely and leave PATH untouched.
- When intervention is needed:
  - Require Homebrew to be installed (bail with a pointer to brew.sh
    otherwise); installing it ourselves would be too invasive.
  - Skip the install if `brew list --formula --quiet bash` reports bash
    is already present.
  - In a TTY, prompt the user before running `brew install bash`
    (default Y, accepts y/yes/Enter). In CI (non-TTY), install silently.
  - Suppress brew's stdio unless CODSPEED_LOG=debug; on failure the
    captured output is included in the error message.
  - Prepend `$(brew --prefix)/bin` to the spawned samply command's PATH
    so brew's unsigned bash wins over other `bash` entries earlier on
    PATH (e.g. nix-profile's signed bash). Only the samply child
    process tree sees this PATH — the parent shell is untouched.

Adds:
- `executor/helpers/homebrew` module with `ensure_installed`,
  `is_installed`, `prefix`, and `install`.
- `CommandBuilder::env()` to set env vars on the spawned process.
@not-matthias not-matthias force-pushed the cod-2649-fix-samply-crashing-due-to-signed-bash branch from b3c84c5 to e26d369 Compare May 13, 2026 02:37
@not-matthias not-matthias merged commit e26d369 into main May 13, 2026
21 checks passed
@not-matthias not-matthias deleted the cod-2649-fix-samply-crashing-due-to-signed-bash branch May 13, 2026 02:50
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