Skip to content

Hide bundled hiredis symbols to avoid cross-extension collisions#396

Open
tillkruss wants to merge 1 commit into
openswoole:masterfrom
tillkruss:fix/hiredis-symbol-visibility
Open

Hide bundled hiredis symbols to avoid cross-extension collisions#396
tillkruss wants to merge 1 commit into
openswoole:masterfrom
tillkruss:fix/hiredis-symbol-visibility

Conversation

@tillkruss

@tillkruss tillkruss commented Jun 15, 2026

Copy link
Copy Markdown

Summary

Fixes #394.

OpenSwoole compiles its bundled hiredis into openswoole.so with default visibility, so every public hiredis symbol (redisConnect, sds*, …) lands in the dynamic symbol table. Another extension linking its own hiredis (e.g. Relay) can then bind to OpenSwoole's coroutine-patched copy depending on load order, causing hangs/crashes — worse on macOS (-flat_namespace).

Fix

Compile the bundled hiredis with -fvisibility=hidden via PHP_ADD_SOURCES_X. Symbols stay usable inside openswoole.so but drop from its exported table on ELF and Mach-O. Objects build/link as before — only the flag is added, and the extension never calls hiredis itself. The issue's "smallest and lowest-risk" option.

Verification

Exported redis*/sds* symbols on the built openswoole.so (nm -gU): 87 → 0, and it still loads and runs.

🤖 Generated with Claude Code

OpenSwoole bundles a coroutine-patched hiredis under thirdparty/hiredis and
compiled its sources into openswoole.so with default symbol visibility, so
every public hiredis symbol (redisConnect, redisCommand, redisReader*, sds*,
...) landed in the module's dynamic symbol table.

As a result, any other extension that links its own hiredis (e.g. Relay) can
have its calls silently bound to OpenSwoole's coroutine-only copy depending on
load order, causing hangs, unexpected yields or crashes. This is worse on
macOS, where PHP links extensions with -flat_namespace.

Compile the bundled hiredis separately with -fvisibility=hidden so its symbols
stay usable within openswoole.so but are dropped from the exported dynamic
symbol table on both ELF (Linux/BSD) and Mach-O (macOS). The extension does not
call hiredis itself, so nothing internal is affected.

Fixes openswoole#394

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tillkruss tillkruss marked this pull request as ready for review June 15, 2026 20: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.

Bundled hiredis exports all public symbols globally, colliding with other extensions that link hiredis

1 participant