Skip to content

Conversation

@darvid
Copy link
Owner

@darvid darvid commented Dec 3, 2025

Summary

  • Add -fvisibility=hidden and -fvisibility-inlines-hidden compile flags
  • Add -Wl,--exclude-libs,ALL linker flag for Linux builds
  • Prevents __cxa_* C++ ABI symbols from being exported

Root Cause

When statically linking C++ libraries (vectorscan, libstdc++), internal symbols like __cxa_allocate_exception, __cxa_throw, __dynamic_cast, etc. were being exported from the shared object. These conflicted with numpy/scipy/sklearn's own C++ code, causing heap corruption and free(): invalid size crashes depending on import order.

Changes

Platform Compile Flags Link Flags
Linux (all) -fvisibility=hidden -fvisibility-inlines-hidden -Wl,--exclude-libs,ALL
macOS -fvisibility=hidden -fvisibility-inlines-hidden (none needed - Apple linker handles visibility differently)
Windows unchanged unchanged

Fixes #247

@darvid darvid force-pushed the fix/247-symbol-visibility-conflict branch from 21c2714 to 4f54b16 Compare December 3, 2025 23:15
…247)

- Add -fvisibility=hidden and -fvisibility-inlines-hidden compile flags
- Add -Wl,--exclude-libs,ALL linker flag for Linux builds
- Prevents __cxa_* C++ ABI symbols from being exported
- Fixes "free(): invalid size" crash when importing hyperscan before sklearn
@darvid darvid changed the title fix(build): hide C++ symbols to prevent conflicts with numpy/sklearn fix(build): hide C++ symbols to prevent conflicts with numpy/sklearn [build] Dec 3, 2025
@darvid darvid force-pushed the fix/247-symbol-visibility-conflict branch from 4f54b16 to f9056aa Compare December 3, 2025 23:17
@darvid darvid changed the title fix(build): hide C++ symbols to prevent conflicts with numpy/sklearn [build] fix(build): hide C++ symbols to prevent conflicts with numpy/sklearn Dec 3, 2025
The workflow was only fetching the base ref but not the PR head ref,
causing git diff to fail silently when comparing commits. This resulted
in CMakeLists.txt changes not being detected properly.
@darvid darvid force-pushed the fix/247-symbol-visibility-conflict branch from d4b6899 to 7407057 Compare December 3, 2025 23:28
@darvid darvid merged commit 46b17c0 into main Dec 4, 2025
56 checks passed
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.

Import order causes free(): invalid size

2 participants