Skip to content

[SofaGLFW, SofaImGui] Fix init calls (and fix import modules from python) - #295

Merged
epernod merged 1 commit into
sofa-framework:masterfrom
fredroy:fix_init_guis
Aug 20, 2026
Merged

[SofaGLFW, SofaImGui] Fix init calls (and fix import modules from python)#295
epernod merged 1 commit into
sofa-framework:masterfrom
fredroy:fix_init_guis

Conversation

@fredroy

@fredroy fredroy commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Had a problem to import SofaImGui in a python script (called directly from python)
It appeared that there was collisions because of the unmangled stuff.
Longer explanation by Claude

The cause: ELF symbol interposition on initExternalModule

initExternalModule is declared extern "C" with default visibility, so it lands in the dynamic symbol table as the plain, unmangled name initExternalModule. Every SOFA plugin does the same thing — 109 libraries in your build export that identical symbol:

$ nm -D --defined-only lib*.so | grep -w initExternalModule   # → 109 hits

Because the caller and callee are in the same shared library but the symbol is global and preemptible, GCC does not bind the call locally. It routes it through the PLT:

0000000000265750 <sofaimgui::init()>:
  ...
  2657a7:  call   1a0f50 <initExternalModule@plt>     ← interposable

At load time, that PLT slot gets filled with whatever initExternalModule is first in the global lookup scope — which is the earliest-loaded plugin, not SofaImGui itself. LD_DEBUG=bindings shows it directly:

binding file libSofaGLFW.so.26.12.99 [0] to libSofaCarving.so [0]: normal symbol `initExternalModule'
binding file libSofaImGui.so.26.12.99 [0] to libSofaCarving.so [0]: normal symbol `initExternalModule'

All the other plugins do this way actually.

@epernod
epernod merged commit 35a9109 into sofa-framework:master Aug 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants