Skip to content

ci: link macOS libevent and memtier against the same OpenSSL - #675

Merged
fcostaoliveira merged 6 commits into
masterfrom
fix/674-macos-openssl-mismatch
Oct 15, 2026
Merged

fcostaoliveira merged 6 commits into
masterfrom
fix/674-macos-openssl-mismatch

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

build-macos (3) fails make check with socket_options_test dying on SIGSEGV on every runner that installs Homebrew's libevent 2.1.13_1 bottle (#674). It intermittently reds every PR's macOS cell, depending on which bottle the runner gets.

Root cause

Homebrew moved libevent to openssl@4 (revision 1). The 3 cell still configured memtier against openssl@3 with Homebrew libevent, so one process loaded two libssl copies and passed an OpenSSL 3 SSL * to libevent's OpenSSL 4 bufferevent_openssl code. scripts/check-macos-tls-links.sh would have caught it, but ran after the unit tests, so the crash came first.

Fix

  • build-macos matrix is now ["3.0", "3", "4"], and every cell builds libevent from source against the cell's OpenSSL (scripts/build-macos-libevent.sh, which the 3.0 cell already used). Homebrew libevent is no longer used there. The first CI run of this PR showed why: on that runner, brew install libevent still served the old 2.1.13 bottle (openssl@3) to an openssl@4 cell. Which OpenSSL Homebrew libevent links depends on the runner's Homebrew snapshot, so it cannot be pinned. The new 4 cell adds OpenSSL 4 coverage. homebrew-core already ships memtier with openssl@4.
  • New job build-macos-homebrew-libevent tests the documented Homebrew path. It runs brew install libevent, picks the OpenSSL with brew deps libevent | grep '^openssl@', configures memtier against that OpenSSL, and runs the link check with "$(brew --prefix libevent)" before make check. The pairing follows Homebrew automatically. The build-macos matrix cells use source-built libevent, so their results do not depend on the runner's Homebrew snapshot.
  • The link check now runs right after "Build" and before "Unit tests" in every macOS job (build-macos, build-macos-openssl-1-1, build-macos-openssl-1-0-2). A mismatch fails with <library>: unexpected OpenSSL dependency <path> (expected under <prefix>) instead of a segfault.
  • check-macos-tls-links.sh prints otool -L for memtier and for every libevent dylib it links. It requires memtier to link libevent_openssl, and it requires both memtier and libevent_openssl to link libssl from the expected OpenSSL prefix.
  • DEVELOPMENT.md macOS section: derive the OpenSSL from Homebrew libevent the same way the CI job does (ssl=$(brew deps libevent | grep '^openssl@' | head -n 1)), or build libevent from source for any other OpenSSL. Each recipe ends with the matching check-macos-tls-links.sh command.

Interaction with #545: the open PR #545 also changes scripts/build-macos-libevent.sh (to a CMake helper), the ci.yml brew install line and DEVELOPMENT.md. Its macOS doc (Homebrew libevent + openssl@3) would reintroduce #674, so whichever PR lands second must resolve this deliberately.

Test evidence

macOS cannot be run locally, so CI is the validation.

The link check detects the #674 mix on a real runner. In run 38696566251 (first commit, where the 4 cell used Homebrew libevent), job 116294385830 failed in the link-check step before any test ran:

Unexpected OpenSSL dependency: /opt/homebrew/opt/openssl@3/lib/libssl.3.dylib
Unexpected OpenSSL dependency: /opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib
/opt/homebrew/opt/libevent/lib/libevent_openssl-2.1.7.dylib does not link libssl from /opt/homebrew/opt/openssl@4/lib/

The first run's messages predate the reworded errors, which now name the library and the expected prefix.

Run 38700109572 (head 9b6e9f1): all six macOS jobs pass. In every job the link check passes before make check, and make check reports 7/7 tests passing, including socket_options_test. memtier and libevent_openssl link a single libssl:

job --version openssl libssl linked by memtier and libevent_openssl
build-macos (3.0) OpenSSL 3.0.22 /opt/homebrew/opt/[email protected]/lib/libssl.3.dylib
build-macos (3) OpenSSL 3.6.4 (#674 crashed on the 3.6.5 runner; 3.6.5 also passed in run 38696891513) /opt/homebrew/opt/openssl@3/lib/libssl.3.dylib
build-macos (4) OpenSSL 4.0.2 /opt/homebrew/opt/openssl@4/lib/libssl.4.dylib
build-macos-homebrew-libevent OpenSSL 3.6.4 ("Homebrew libevent depends on openssl@3") /opt/homebrew/opt/openssl@3/lib/libssl.3.dylib
build-macos-openssl-1-1 OpenSSL 1.1.1w /opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib
build-macos-openssl-1-0-2 OpenSSL 1.0.2u /opt/homebrew/opt/[email protected]/lib/libssl.1.0.0.dylib

On this runner Homebrew still served the old libevent bottle, which links openssl@3, so the Homebrew job picked openssl@3. OpenSSL 4 is therefore covered only by the source-built build-macos (4) cell. Once runners get libevent 2.1.13_1, the Homebrew job will pick openssl@4 on its own.

I also checked the script on Linux with a stub otool: memtier -> openssl@3 with libevent_openssl -> openssl@4 exits 1, and the matching pair exits 0.

Fixes #674

Affected versions

master only (CI only); no release is affected.

  • The brew install libevent + openssl@3 CI cell came in with 76b2b8f (Initialize TCP keepalive and no-delay socket options #541), which no release tag contains. The crash started when Homebrew published libevent 2.1.13_1 (OpenSSL 4) on 2026-10-08.
  • Users building any release on macOS by following the old DEVELOPMENT.md (Homebrew libevent + [email protected]) get the same mixed-OpenSSL binary once their Homebrew libevent is on openssl@4. This is derived from the CI evidence and was not run. The DEVELOPMENT.md change addresses it.

🤖 Generated with Claude Code


Note

Low Risk
Changes are limited to macOS CI, helper scripts, and developer docs; no runtime application code is modified.

Overview
Fixes intermittent macOS CI failures (#674) where memtier and Homebrew libevent linked different OpenSSL copies and TLS unit tests segfaulted instead of failing clearly.

CI: The build-macos matrix now includes OpenSSL 4 and every cell builds libevent from source against that cell’s OpenSSL (Homebrew libevent is no longer used there). A new build-macos-homebrew-libevent job covers the documented Homebrew path by resolving OpenSSL via brew deps libevent. On all macOS jobs, check-macos-tls-links.sh runs after build and before make check.

Scripts: build-macos-libevent.sh wipes stale libevent trees, ensures the build root exists, and passes --disable-debug-mode. check-macos-tls-links.sh requires libevent_openssl, verifies memtier and libevent share the expected OpenSSL prefix, and prints clearer per-library errors.

Docs: DEVELOPMENT.md explains matching Homebrew libevent’s OpenSSL (or building libevent from source for another version) and documents the link-check commands.

Reviewed by Cursor Bugbot for commit 9eb200d. Bugbot is set up for automated code reviews on this repo. Configure here.

fcostaoliveira and others added 6 commits October 15, 2026 08:06
Homebrew's libevent 2.1.13_1 now depends on openssl@4, but the
build-macos "3" cell still built memtier against openssl@3 with
Homebrew libevent. The process loaded two libssl copies and passed an
OpenSSL 3 SSL* to libevent's OpenSSL 4 bufferevent_openssl code, so
socket_options_test segfaulted on every runner with the new bottle.

- build-macos: the 3.0 and 3 cells build libevent from source against
  the cell's OpenSSL. A new 4 cell uses Homebrew libevent with openssl@4,
  which is Homebrew's consistent pair and what DEVELOPMENT.md now
  recommends.
- Run scripts/check-macos-tls-links.sh after Build and before the unit
  tests in all macOS jobs, so a library mismatch fails with a clear
  message instead of a crash.
- check-macos-tls-links.sh now prints the otool output of each checked
  library, requires memtier to link libevent_openssl, and requires both
  memtier and libevent_openssl to link libssl from the expected prefix.
- DEVELOPMENT.md: use openssl@4 with Homebrew libevent and explain how
  to use another OpenSSL.

Fixes #674

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first CI run showed the runner's Homebrew still serving libevent
2.1.13 (openssl@3) to the new openssl@4 cell, so which OpenSSL Homebrew
libevent links depends on the runner snapshot. The link check caught it
before the tests. Build libevent against the cell's OpenSSL in every
cell, and tell DEVELOPMENT.md readers to check brew deps libevent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- build-macos-libevent.sh: create RUNNER_TEMP before downloading, so
  the DEVELOPMENT.md recipe works on a clean machine.
- DEVELOPMENT.md: install the alternative OpenSSL first.
- Drop the otool -L greps in build-macos-openssl-1-1; the link check
  prints otool -L itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build memtier exactly as DEVELOPMENT.md says: Homebrew libevent and the
OpenSSL it depends on (brew deps libevent), with the link check before
the unit tests. The pairing follows Homebrew automatically. Also build
the source libevent with --disable-debug-mode, matching the formula.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… errors

DEVELOPMENT.md hard-coded openssl@4, but the OpenSSL Homebrew libevent
links depends on its revision (today's runner still had openssl@3).
Derive it with brew deps exactly as the CI job does, and show how to run
check-macos-tls-links.sh after building. The link check now names the
library and the expected prefix in its errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Re-running the script into the same RUNNER_TEMP with another OpenSSL
kept the old objects (tar restores timestamps, config.h is unchanged),
so the old libevent_openssl was reinstalled. Remove the script's own
build and install directories first. Also print a message when brew
deps libevent lists no OpenSSL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fcostaoliveira
fcostaoliveira merged commit 4eae3ef into master Oct 15, 2026
129 checks passed
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.

socket_options_test segfaults in build-macos (3): Homebrew libevent now links OpenSSL 4, memtier links openssl@3

1 participant