Skip to content

Fix: ASAN ODR violation when loading both extensions#1659

Merged
jahnvi480 merged 3 commits into
devfrom
jahnvi/fix-ghi-1632-odr-violation
Jun 17, 2026
Merged

Fix: ASAN ODR violation when loading both extensions#1659
jahnvi480 merged 3 commits into
devfrom
jahnvi/fix-ghi-1632-odr-violation

Conversation

@jahnvi480

Copy link
Copy Markdown
Contributor

GHI #1632

This pull request introduces a new Dockerfile for reproducing and testing AddressSanitizer (ASAN) ODR (One Definition Rule) violations when loading both the sqlsrv and pdo_sqlsrv PHP 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:

  • Added a new Dockerfile-asan-test that automates building PHP with ASAN, compiling both sqlsrv and pdo_sqlsrv extensions 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 loading sqlsrv and pdo_sqlsrv extensions #1632.

Build Configuration Hardening:

  • Updated source/sqlsrv/config.m4 to add the -fvisibility=hidden compiler flag, which restricts symbol visibility to prevent accidental symbol clashes between extensions.
  • Updated source/pdo_sqlsrv/config.m4 to add the -fvisibility=hidden compiler flag for the same purpose.

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

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.76%. Comparing base (4d1fd72) to head (e843581).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files

Impacted file tree graph

@@            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     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants