Skip to content

SofaPython3 import leads to segfault - #141

Open
p-shg wants to merge 1 commit into
SofaDefrost:masterfrom
p-shg:sofapython3_segfault_fix
Open

p-shg wants to merge 1 commit into
SofaDefrost:masterfrom
p-shg:sofapython3_segfault_fix

Conversation

@p-shg

@p-shg p-shg commented Oct 9, 2026

Copy link
Copy Markdown

When a scene is created from a Python script (import Sofa, e.g. Gym-style environments, tests, batch simulations), the scene initializes and animates correctly but the process segfaults when Python exits (exit code 139).
Loading SofaPython3 through the PluginManager (RequiredPlugin or SofaRuntime.importPlugin("SofaPython3")) seems to trigger it.
A scene with no RequiredPlugin on SofaPython3 exits cleanly.

Loading SofaPython3 manually seems to be never needed:

  • runSofa already loads SofaPython3 when reading .py scene
  • python already loads through import Sofa

Loading SofaPython3 twice through the PluginManager may need to raise a warning or error in SofaPython3

MainHeader, Scene.addMainHeader and Settings always appended
"SofaPython3" to the plugins list. When a scene is built from a Python
script (import Sofa) and not from runSofa, this RequiredPlugin loads
libSofaPython3.so a second time through the PluginManager, and the
process segfaults at interpreter exit.
@p-shg
p-shg requested review from bakpaul and damienmarchal October 9, 2026 14:57
@p-shg

p-shg commented Oct 9, 2026

Copy link
Copy Markdown
Author

I also use Black formatter which may have triggered more changes in the files than strictly necessary, let me know if I should set different arguments to the formatter
I do believe the indentation was wrong/confusing though

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.

1 participant