Fix: ASAN ODR violation when loading both extensions#1659
Merged
Conversation
Add -fvisibility=hidden to CXXFLAGS in both config.m4 files. This makes all symbols library-private by default, preventing ASAN from detecting duplicate global definitions when sqlsrv.so and pdo_sqlsrv.so are loaded together. The get_module() entry point remains exported via ZEND_DLEXPORT which explicitly sets visibility(default). This is not a regression — the ODR violation has existed since the first commit (v2.0, 2010) but was only detected now that ASAN-enabled PHP builds are being created for the setup-php GitHub Action. Fixes #1632
Builds PHP from source with --enable-address-sanitizer, compiles both extensions with -fsanitize=address, and verifies they load together without ASAN errors. Useful for validating future changes against ASAN.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1659 +/- ##
==========================================
+ Coverage 85.72% 85.76% +0.03%
==========================================
Files 23 23
Lines 7210 7207 -3
==========================================
Hits 6181 6181
+ Misses 1029 1026 -3 🚀 New features to boost your workflow:
|
bewithgaurav
approved these changes
Jun 17, 2026
This was referenced Jun 18, 2026
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.
GHI #1632
This pull request introduces a new Dockerfile for reproducing and testing AddressSanitizer (ASAN) ODR (One Definition Rule) violations when loading both the
sqlsrvandpdo_sqlsrvPHP extensions together. Additionally, it updates the build configuration for both extensions to improve symbol visibility and help prevent symbol conflicts, which are a common source of ODR violations.Key changes include:
ASAN ODR Violation Reproduction and Testing:
Dockerfile-asan-testthat automates building PHP with ASAN, compiling bothsqlsrvandpdo_sqlsrvextensions with matching sanitizer flags, and running tests to detect ODR violations when both extensions are loaded. This provides a reproducible environment for debugging and verifying fixes for GitHub Issue ODR violation when loadingsqlsrvandpdo_sqlsrvextensions #1632.Build Configuration Hardening:
source/sqlsrv/config.m4to add the-fvisibility=hiddencompiler flag, which restricts symbol visibility to prevent accidental symbol clashes between extensions.source/pdo_sqlsrv/config.m4to add the-fvisibility=hiddencompiler flag for the same purpose.