Segmentation fault when using eigen library in addon #93622
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#93622
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Linux-5.15.5-arch1-1-x86_64-with-glibc2.33 64 Bits
Graphics card: NVIDIA GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 495.44
Blender Version
Broken: version: 3.0.0, branch: master, commit date: 2021-12-02 18:35, hash:
f1cca30557
Worked: -
Short description of error
I'm currently working on an addon that integrates a physics engine, written in c++ that heavily depends on eigen library. This engine also uses swig to create python bindings.
The problem is that this library crashes blender with segmentation fault.
I tried to compile the engine with the eigen version from blender repo, but with no luck.
I can run the same python code without blender with no issues.
I assembled the minimal example that can show the same issue.
I also supplied crash.txt from the original addon; blender.crash.txt from the minimal example and console output from minimal example
Exact steps for others to reproduce the error
Extract cpp_test.zip, it should have the following directory structure
Edit paths to includes in build.sh
run build.sh from cpp directory(you should have swig, eigen and python headers installed in your system for this to work)
Install cpp_test as an addon and try to enable it.
It will crash blender with segmentation fault
cpp_test.zip
blender.crash.txt
blender_output.txt
original.crash.txt
Added subscriber: @Sergey-Morozov
It also seems that I'm not the first one to experience this problem. I found this thread on stackoverflow with similar issue. https://stackoverflow.com/questions/62470601/c-python-module-crashes-in-blender-but-not-in-python-console
I found a workaround, we can just run the target function in subprocess, using 'spawn' start method.
Unfortunately, this way the function won't have access to
bpy
module and we need to think about inter-process communication, but at least it works.(The original post problem still should be considered a bug, and this workaround is just for anyone who will stumble upon this issue later)
Found another project with similar issue(and the same workaround works for it)
https://github.com/taichi-dev/taichi/issues/1990
https://github.com/taichi-dev/taichi_blend/issues/1
Added subscriber: @lichtwerk
Changed status from 'Needs Triage' to: 'Needs User Info'
This is our guidleline on cases like these:
So if you can identify the error in Blender's code that would be good.
Poke ^^
(otherwise will be closed next week I am afraid)
Sorry for late answer, I was rather busy lately.
I'm not very good at c++ development, but after some debugging on master branch it seems like I found a problem.
At some point eigen library which is compiled into an
_example.so
tries to callIOFormat()
constructor, but instead of calling this method from an_example.so
it finds it in blender executable which causes memory corruption and segmentation fault when accessing arowSpacer
member of a resulting object.Here is the simplified version of an
example.cpp
which causes the issue.If I understand correctly the issue is that by default g++(and other compilers) make most symbols weak so they can be overridden by other symbols. This can be solved by just compiling the shared library with
-fvisibility=hidden
flag like thisg++ -g -ggdb -fPIC example.cpp example_wrap.c -I /usr/include/python3.10/ -I /usr/include/eigen3/ -shared -fvisibility=hidden -o _example.so
Then the symbols in the resulting library will be created as text.
I tried this on blender 3.0.1 and 3.2.0 Alpha(master branch) with this example and taichi library and it looks like it's working.
I don't know if this is a proper solution, but It still might be considered a blender related bug, because it might not be always possible to recompile shared libraries(for example, when integrating something proprietary).
Changed status from 'Needs User Info' to: 'Needs Triage'
Added subscriber: @OmarEmaraDev
Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Not sure if there is something Blender can do here, I can't find similar reports, so this needs a look from a developer.