Segfault on Linux when running third-party Python library function #109551

Closed
opened 2023-06-30 11:29:32 +02:00 by Dion Moult · 2 comments

System Information
Operating system: Linux
Graphics card: N/A

Blender Version
Broken:Blender 3.5 stable for Linux downloaded from Blender.org, and Blender 3.6 stable for Linux downloaded from Blender.org
Worked: Blender 3.4 stable for Linux downloaded from Blender.org, or any version of Blender for Windows or MacOS (including M1)

I'm the primary developer of the BlenderBIM Add-on (https://blenderbim.org/) which provides import / export support for the .ifc format for architects and engineers in Blender. One of the addon's functionality around the "hppfcl" C++ library with Python bindings. One of the functions of hppfcl is to create triangulated geometry.

This functionality has worked for a very long time since Blender 3.0 days but with Blender 3.5 and onwards (including 3.6) it has been segfaulting randomly. The last stable version it worked was 3.4. The hppfcl library I am loading is unchanged. Note that the segfault only occurs on Linux using the Linux release downloaded from Blender.org. No segfault occurs on Windows or MacOS including M1.

I understand this is not core Blender functionality, so I apologise if this is the wrong channel, but maybe it is a symptom of other issues in Blender. There are also lots of users of the add-on who depend on this (there is no other way to load building data into Blender) so I hope I have helped unearth an issue.

The crash error log is pretty empty.

# Blender 3.5.0, Commit date: 2023-03-29 02:56, Hash 1be25cfff18b
bpy.ops.text.run_script()  # Operator

# backtrace

# Python backtrace
  File "/home/dion/untitled.blend/Text", line 46 in <module>

Running with gdb (note no debugging symbols) isn't very insightful either:

gdb ./blender                                                                                                                                                                                          :) 
GNU gdb (Gentoo 13.2 vanilla) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./blender...
(No debugging symbols found in ./blender)
(gdb) run -b -P /home/dion/Projects/ifcopenshell/src/blenderbim/scripts/clashtest.py
Starting program: /home/dion/drive/blender/blender-3.5.0-linux-x64/blender -b -P /home/dion/Projects/ifcopenshell/src/blenderbim/scripts/clashtest.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffea1ff680 (LWP 28553)]
[New Thread 0x7fffe7865680 (LWP 28554)]
[New Thread 0x7fffe7064680 (LWP 28555)]
[New Thread 0x7fffe6863680 (LWP 28556)]
[New Thread 0x7fffe6062680 (LWP 28557)]
[New Thread 0x7fffe5861680 (LWP 28558)]
[New Thread 0x7fffe5060680 (LWP 28559)]
[New Thread 0x7fffe485f680 (LWP 28560)]
[New Thread 0x7fffe405e680 (LWP 28561)]
[New Thread 0x7fffe385d680 (LWP 28562)]
[New Thread 0x7fffe305c680 (LWP 28563)]
[New Thread 0x7fffe285b680 (LWP 28564)]
[New Thread 0x7fffe205a680 (LWP 28565)]
Blender 3.5.0 (hash 1be25cfff18b built 2023-03-29 06:35:04)
Read prefs: /home/dion/.config/blender/3.5/config/userpref.blend
[New Thread 0x7fffdc7ff680 (LWP 28566)]
[New Thread 0x7fffdb9ff680 (LWP 28567)]
[New Thread 0x7fffcf1fe680 (LWP 28568)]
[New Thread 0x7fffce3ff680 (LWP 28569)]
Failed to open dir (No such file or directory): /run/user/1000/gvfs/
Warning: GitPython not available.
[New Thread 0x7fffb66ff680 (LWP 28570)]
[New Thread 0x7fffb62fe680 (LWP 28571)]
[New Thread 0x7fffb59ff680 (LWP 28572)]
[New Thread 0x7fffb51fe680 (LWP 28573)]
[New Thread 0x7fffb47ff680 (LWP 28574)]
[New Thread 0x7fffb41fe680 (LWP 28575)]
[New Thread 0x7fffb3dfd680 (LWP 28576)]
[New Thread 0x7fffb33ff680 (LWP 28577)]
[New Thread 0x7fffb2dfe680 (LWP 28578)]
[New Thread 0x7fffb23ff680 (LWP 28579)]
[New Thread 0x7fffb17ff680 (LWP 28580)]
[New Thread 0x7fffb11fe680 (LWP 28581)]

Thread 1 "blender" received signal SIGSEGV, Segmentation fault.
0x00000000008ac33d in PyObject_GC_UnTrack ()
(gdb) bt
#0  0x00000000008ac33d in PyObject_GC_UnTrack ()
#1  0x0000000000865557 in ?? ()
#2  0x000000000084a815 in ?? ()
#3  0x0000000000888ff3 in _PyEval_EvalFrameDefault ()
#4  0x0000000000886362 in ?? ()
#5  0x000000000985d002 in PyEval_EvalCode ()
#6  0x0000000009870994 in ?? ()
#7  0x000000000987091b in ?? ()
#8  0x00000000006d2757 in ?? ()
#9  0x00000000006d3a06 in PyRun_FileExFlags ()
#10 0x00000000013c1565 in ?? ()
#11 0x00000000008d5655 in ?? ()
#12 0x000000000975bfa1 in ?? ()
#13 0x000000000073ab73 in ?? ()
#14 0x00007fffeae4a2ca in ?? () from /lib64/libc.so.6
#15 0x00007fffeae4a385 in __libc_start_main () from /lib64/libc.so.6
#16 0x00000000008d3b3e in ?? ()

Exact steps for others to reproduce the error
Based on the default startup or an attached .blend file (as simple as possible).

  1. Make sure you are on Linux and using the Blender 3.5 stable release from Blender.org (i.e. not from distro package)
  2. Download, install, and enable the BlenderBIM Add-on https://github.com/IfcOpenShell/IfcOpenShell/releases/download/blenderbim-230630/blenderbim-230630-py310-linux.zip - this will give you the hppfcl library
  3. Launch Blender, and run this in the text editor. You may need to run it several times to trigger a crash (it is semi-random).
import hppfcl
import numpy as np
v = (-1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0)
f = (2, 0, 1, 3, 2, 1, 5, 4, 6, 5, 6, 7, 0, 4, 5, 1, 0, 5, 7, 6, 2, 7, 2, 3, 0, 2, 6, 4, 0, 6, 7, 3, 1, 7, 1, 5)
mesh_verts = np.array([[v[i], v[i + 1], v[i + 2]] for i in range(0, len(v), 3)])
mesh_faces = [(int(f[i]), int(f[i + 1]), int(f[i + 2])) for i in range(0, len(f), 3)]
triangles = hppfcl.StdVec_Triangle()
for f in mesh_faces:
    tri = hppfcl.Triangle(f[0], f[1], f[2]) # Segfaults here
    triangles.append(tri)
**System Information** Operating system: Linux Graphics card: N/A **Blender Version** Broken:Blender 3.5 stable for Linux downloaded from Blender.org, and Blender 3.6 stable for Linux downloaded from Blender.org Worked: Blender 3.4 stable for Linux downloaded from Blender.org, or any version of Blender for Windows or MacOS (including M1) I'm the primary developer of the BlenderBIM Add-on (https://blenderbim.org/) which provides import / export support for the .ifc format for architects and engineers in Blender. One of the addon's functionality around the "hppfcl" C++ library with Python bindings. One of the functions of hppfcl is to create triangulated geometry. This functionality has worked for a very long time since Blender 3.0 days but with Blender 3.5 and onwards (including 3.6) it has been segfaulting randomly. The last stable version it worked was 3.4. The hppfcl library I am loading is unchanged. Note that the segfault only occurs on Linux using the Linux release downloaded from Blender.org. No segfault occurs on Windows or MacOS including M1. I understand this is not core Blender functionality, so I apologise if this is the wrong channel, but maybe it is a symptom of other issues in Blender. There are also lots of users of the add-on who depend on this (there is no other way to load building data into Blender) so I hope I have helped unearth an issue. The crash error log is pretty empty. ``` # Blender 3.5.0, Commit date: 2023-03-29 02:56, Hash 1be25cfff18b bpy.ops.text.run_script() # Operator # backtrace # Python backtrace File "/home/dion/untitled.blend/Text", line 46 in <module> ``` Running with `gdb` (note no debugging symbols) isn't very insightful either: ``` gdb ./blender  :) GNU gdb (Gentoo 13.2 vanilla) 13.2 Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://bugs.gentoo.org/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./blender... (No debugging symbols found in ./blender) (gdb) run -b -P /home/dion/Projects/ifcopenshell/src/blenderbim/scripts/clashtest.py Starting program: /home/dion/drive/blender/blender-3.5.0-linux-x64/blender -b -P /home/dion/Projects/ifcopenshell/src/blenderbim/scripts/clashtest.py [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". [New Thread 0x7fffea1ff680 (LWP 28553)] [New Thread 0x7fffe7865680 (LWP 28554)] [New Thread 0x7fffe7064680 (LWP 28555)] [New Thread 0x7fffe6863680 (LWP 28556)] [New Thread 0x7fffe6062680 (LWP 28557)] [New Thread 0x7fffe5861680 (LWP 28558)] [New Thread 0x7fffe5060680 (LWP 28559)] [New Thread 0x7fffe485f680 (LWP 28560)] [New Thread 0x7fffe405e680 (LWP 28561)] [New Thread 0x7fffe385d680 (LWP 28562)] [New Thread 0x7fffe305c680 (LWP 28563)] [New Thread 0x7fffe285b680 (LWP 28564)] [New Thread 0x7fffe205a680 (LWP 28565)] Blender 3.5.0 (hash 1be25cfff18b built 2023-03-29 06:35:04) Read prefs: /home/dion/.config/blender/3.5/config/userpref.blend [New Thread 0x7fffdc7ff680 (LWP 28566)] [New Thread 0x7fffdb9ff680 (LWP 28567)] [New Thread 0x7fffcf1fe680 (LWP 28568)] [New Thread 0x7fffce3ff680 (LWP 28569)] Failed to open dir (No such file or directory): /run/user/1000/gvfs/ Warning: GitPython not available. [New Thread 0x7fffb66ff680 (LWP 28570)] [New Thread 0x7fffb62fe680 (LWP 28571)] [New Thread 0x7fffb59ff680 (LWP 28572)] [New Thread 0x7fffb51fe680 (LWP 28573)] [New Thread 0x7fffb47ff680 (LWP 28574)] [New Thread 0x7fffb41fe680 (LWP 28575)] [New Thread 0x7fffb3dfd680 (LWP 28576)] [New Thread 0x7fffb33ff680 (LWP 28577)] [New Thread 0x7fffb2dfe680 (LWP 28578)] [New Thread 0x7fffb23ff680 (LWP 28579)] [New Thread 0x7fffb17ff680 (LWP 28580)] [New Thread 0x7fffb11fe680 (LWP 28581)] Thread 1 "blender" received signal SIGSEGV, Segmentation fault. 0x00000000008ac33d in PyObject_GC_UnTrack () (gdb) bt #0 0x00000000008ac33d in PyObject_GC_UnTrack () #1 0x0000000000865557 in ?? () #2 0x000000000084a815 in ?? () #3 0x0000000000888ff3 in _PyEval_EvalFrameDefault () #4 0x0000000000886362 in ?? () #5 0x000000000985d002 in PyEval_EvalCode () #6 0x0000000009870994 in ?? () #7 0x000000000987091b in ?? () #8 0x00000000006d2757 in ?? () #9 0x00000000006d3a06 in PyRun_FileExFlags () #10 0x00000000013c1565 in ?? () #11 0x00000000008d5655 in ?? () #12 0x000000000975bfa1 in ?? () #13 0x000000000073ab73 in ?? () #14 0x00007fffeae4a2ca in ?? () from /lib64/libc.so.6 #15 0x00007fffeae4a385 in __libc_start_main () from /lib64/libc.so.6 #16 0x00000000008d3b3e in ?? () ``` **Exact steps for others to reproduce the error** Based on the default startup or an attached .blend file (as simple as possible). 1. Make sure you are on Linux and using the Blender 3.5 stable release from Blender.org (i.e. not from distro package) 2. Download, install, and enable the BlenderBIM Add-on https://github.com/IfcOpenShell/IfcOpenShell/releases/download/blenderbim-230630/blenderbim-230630-py310-linux.zip - this will give you the hppfcl library 3. Launch Blender, and run this in the text editor. You may need to run it several times to trigger a crash (it is semi-random). ``` import hppfcl import numpy as np v = (-1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0) f = (2, 0, 1, 3, 2, 1, 5, 4, 6, 5, 6, 7, 0, 4, 5, 1, 0, 5, 7, 6, 2, 7, 2, 3, 0, 2, 6, 4, 0, 6, 7, 3, 1, 7, 1, 5) mesh_verts = np.array([[v[i], v[i + 1], v[i + 2]] for i in range(0, len(v), 3)]) mesh_faces = [(int(f[i]), int(f[i + 1]), int(f[i + 2])) for i in range(0, len(f), 3)] triangles = hppfcl.StdVec_Triangle() for f in mesh_faces: tri = hppfcl.Triangle(f[0], f[1], f[2]) # Segfaults here triangles.append(tri) ```
Dion Moult added the
Type
Report
Status
Needs Triage
Priority
Normal
labels 2023-06-30 11:29:33 +02:00
Member

I'm not sure if you could but it would be best if you manage to get symbols for stack trace (like from a debug build). Currently we are probably unable to determine if it's the problem of blender or hppfcl. The script here doesn't seem to interact with blender API so it's probably not the problem with blender.

Blender 3.4 uses python 3.10.8 but Blender 3.5 uses python 3.10.9, maybe it can affect hppfcl.

_PyEval_EvalFrameDefault does indicate it crashed during evaluation somewhere in cpython.

I'm not sure if you could but it would be best if you manage to get symbols for stack trace (like from a debug build). Currently we are probably unable to determine if it's the problem of blender or hppfcl. The script here doesn't seem to interact with blender API so it's probably not the problem with blender. Blender 3.4 uses python 3.10.8 but Blender 3.5 uses python 3.10.9, maybe it can affect hppfcl. `_PyEval_EvalFrameDefault` does indicate it crashed during evaluation somewhere in cpython.
Author

@ChengduLittleA thanks for the tip! I think you're right the minor version bump would've led to an incompatibility on the hppfcl side. I've managed to fix it by upgrading hppfcl! Thank so much for the help and confirming that this bug is not related to Blender.

@ChengduLittleA thanks for the tip! I think you're right the minor version bump would've led to an incompatibility on the hppfcl side. I've managed to fix it by upgrading hppfcl! Thank so much for the help and confirming that this bug is not related to Blender.
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-07-01 09:42:30 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#109551
No description provided.