Skip to content

Avoid eager PatchELF signature evaluation - #23636

Merged
p-linnane merged 2 commits into
mainfrom
patchelf-lazy-signature
Aug 23, 2026
Merged

Avoid eager PatchELF signature evaluation#23636
p-linnane merged 2 commits into
mainfrom
patchelf-lazy-signature

Conversation

@MikeMcQuaid

Copy link
Copy Markdown
Member

Fixes a flaky test.

  • Keep PatchELF lazy while allowing patch-first calls
  • Cover patching before metadata loads the dependency

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

OpenAI Codex 5.6 high with local review and testing.


- Keep `PatchELF` lazy while allowing patch-first calls
- Cover patching before metadata loads the dependency
Copilot AI lite review requested due to automatic review settings August 23, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a flaky Linux ELF patching scenario by preventing Sorbet runtime signature evaluation from eagerly resolving PatchELF before patchelf is required, and adds coverage for calling patch! before any metadata access.

Changes:

  • Switch patchelf_patcher to T::Sig::WithoutRuntime.sig to avoid eager ::PatchELF constant resolution during file load.
  • Add a Linux spec case intended to cover patching-before-metadata behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Library/Homebrew/os/linux/elf.rb Avoids eager PatchELF constant resolution by using T::Sig::WithoutRuntime.sig for patchelf_patcher.
Library/Homebrew/test/os/linux/pathname_spec.rb Adds a new example around calling patch! without first reading ELF metadata.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread Library/Homebrew/os/linux/elf.rb
Comment thread Library/Homebrew/test/os/linux/pathname_spec.rb Outdated
Signed-off-by: Patrick Linnane <patrick@linnane.io>
@p-linnane
p-linnane enabled auto-merge August 23, 2026 21:42
@p-linnane
p-linnane added this pull request to the merge queue Aug 23, 2026
Merged via the queue into main with commit ba9b399 Aug 23, 2026
45 checks passed
@p-linnane
p-linnane deleted the patchelf-lazy-signature branch August 23, 2026 22:24
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.

3 participants