mirror of
https://github.com/coturn/coturn.git
synced 2026-10-24 00:08:57 +03:00
## Problem Every macOS job in CI currently fails: `turnserver` segfaults on the first TLS client in `examples/run_tests.sh` (e.g. run 37231739523 on #2093, which only touches `dbd_sqlite.c`). Cause: Homebrew's `openssl` formula now resolves to `openssl@4` (4.0.3), but the libevent bottle's `libevent_openssl` still links `openssl@3`. coturn builds against OpenSSL 4 and passes its `SSL*` to libevent running on OpenSSL 3 via `bufferevent_openssl_socket_new`, which crashes in `SSL_set_bio`. macOS two-level namespaces keep both copies loaded. ## Changes - `.github/workflows/macos.yml`: install `openssl@3` and export `OPENSSL_ROOT_DIR` / `PKG_CONFIG_PATH` for both the autotools and CMake jobs. - `cmake/CheckLibeventOpenSSL.cmake` (new), used from `src/apps/common/CMakeLists.txt`: on macOS, fail configure when `libevent_openssl` links a different OpenSSL major than the one found. - `configure`: same check for the autotools build (Darwin only). - `TURN_ALLOW_OPENSSL_MISMATCH` (CMake option / env var) overrides the check. ## Testing On macOS (both `openssl@3` 3.6.5 and `openssl@4` 4.0.3 installed): - CMake configure with the default OpenSSL (`openssl@4`) fails with the new error. With `-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@3)` it passes, and `-DTURN_ALLOW_OPENSSL_MISMATCH=ON` also passes. - `./configure` with `openssl@4` first on `PKG_CONFIG_PATH` aborts; with `openssl@3` first it passes, and the override also passes. - With the `openssl@3` build: `ctest` 21/21, and `run_tests.sh` (TCP/TLS/UDP/DTLS), `run_tests_conf`, `dtls_default`, `ipv6_relay`, `mobility_quota`, `mobility_resume_flood`, `stateless_binding`, `stateless_nonce` all pass with no FAIL or segfault. On Linux (Docker): CMake configure, build and `ctest` (20/20) pass; the check is a no-op there. I did not complete the Linux `run_tests*.sh` pass. The PR's own macOS CI jobs are the real end-to-end check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
45 lines
1.9 KiB
CMake
45 lines
1.9 KiB
CMake
# Fail configure when libevent_openssl is linked against a different OpenSSL
|
|
# major version than the one coturn builds with.
|
|
#
|
|
# On macOS two-level namespaces keep both copies loaded in one process, and an
|
|
# SSL* created by one OpenSSL gets handed to the other through
|
|
# bufferevent_openssl_socket_new(), which crashes in SSL_set_bio. Typical
|
|
# trigger: Homebrew's `openssl` formula moving to a new major while libevent
|
|
# still depends on the previous one.
|
|
#
|
|
# turn_check_libevent_openssl_abi(<libevent_openssl library> <OpenSSL major>)
|
|
function(turn_check_libevent_openssl_abi event_openssl_lib ssl_major)
|
|
if(NOT APPLE OR NOT event_openssl_lib OR TURN_ALLOW_OPENSSL_MISMATCH)
|
|
return()
|
|
endif()
|
|
|
|
find_program(TURN_OTOOL otool)
|
|
if(NOT TURN_OTOOL)
|
|
return()
|
|
endif()
|
|
|
|
execute_process(COMMAND ${TURN_OTOOL} -L "${event_openssl_lib}"
|
|
OUTPUT_VARIABLE _otool_out
|
|
RESULT_VARIABLE _otool_rc
|
|
ERROR_QUIET)
|
|
if(NOT _otool_rc EQUAL 0)
|
|
return()
|
|
endif()
|
|
|
|
# libssl.3.dylib / libcrypto.3.dylib: the number is the OpenSSL soname major.
|
|
string(REGEX MATCHALL "lib(ssl|crypto)\\.[0-9]+(\\.[0-9]+)*\\.dylib" _deps "${_otool_out}")
|
|
foreach(_dep ${_deps})
|
|
string(REGEX REPLACE "^lib(ssl|crypto)\\.([0-9]+).*$" "\\2" _dep_major "${_dep}")
|
|
if(NOT _dep_major STREQUAL ssl_major)
|
|
message(FATAL_ERROR
|
|
"libevent_openssl (${event_openssl_lib}) links ${_dep}, but coturn is "
|
|
"building against OpenSSL ${ssl_major}.x. Mixing two OpenSSL majors "
|
|
"crashes turnserver on the first TLS connection.\n"
|
|
"Point CMake at the OpenSSL libevent uses (e.g. "
|
|
"-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@${_dep_major})), or rebuild "
|
|
"libevent against OpenSSL ${ssl_major}. Override with "
|
|
"-DTURN_ALLOW_OPENSSL_MISMATCH=ON.")
|
|
endif()
|
|
endforeach()
|
|
endfunction()
|