Hide bundled hiredis symbols to avoid cross-extension collisions#396
Open
tillkruss wants to merge 1 commit into
Open
Hide bundled hiredis symbols to avoid cross-extension collisions#396tillkruss wants to merge 1 commit into
tillkruss wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #394.
OpenSwoole compiles its bundled hiredis into
openswoole.sowith 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=hiddenviaPHP_ADD_SOURCES_X. Symbols stay usable insideopenswoole.sobut 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 builtopenswoole.so(nm -gU): 87 → 0, and it still loads and runs.🤖 Generated with Claude Code