Crash using 'ctypes' (fixed in Python >= 3.8), causes crashes in A.N.T. Landscape and various other addons #84752
Labels
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
9 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#84752
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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: Ubuntu 20.10, Linux-5.8.0-38-generic-x86_64-with-glibc2.17 64 Bits
Graphics card: Mesa DRI Intel(R) HD Graphics 620 (KBL GT2) Intel Open Source Technology Center 4.6 (Core Profile) Mesa 20.3.1 (git-d90622910b)
CPU: Intel Core i5-7200U
Not reproducible on Ubuntu 20.04.
Addon Information
Name: A.N.T.Landscape (0, 1, 8)
Author: Jimmy Hazevoet
Blender Version
Broken:
0f45cab862
, type: Release Snap and portableb5c3f26cba
, type: Release portable442b6e5e09
, type: Release snapWorked:
0f45cab862
, type: Release FlatpakShort description of error
Whenever I want to enable the A.N.T. Landscape Addon by clicking the little box it crashes blender to desktop. This happens in the package installed via official Snap. It does work in the flatpak version however...
Exact steps for others to reproduce the error
Analysis
The problem appears to be caused by the call to
CFUNCTYPE(c_int)(lambda: None)
by_reset_cache()
in[version]/python/lib/python3.7/ctypes/__init__.py
. This line appears to have been added as workaround for a failing test, but has since been removed from by the following commit:e6b247c8e5 (diff-edff4421a88bdc56335a84a1e5a0ce0eafe5cd0c37dcb1aff03ff075bfb9b57c)
It was originally added by commit:
674e9389e9
Removing the line in question prevents the crash.
Older information:
What I've tried so far but did'nt help
scripts/addons/ant_landscape/__pycache__/*
system-info.txt
of both versions - except for flatpak / snap specific file paths there identical (Build flags, Python version, other enabled addons etc.)debugging information
I ran Blender with
blender --debug --debug-gpu > ~/blender_debug_output.txt 2>&1
as recommended by @rjg file only contains:The core dump is nowhere to be found, neither the blender crash log. I looked through
/tmp
(only contains quit.blend file) and/var/crash
, nothing there.I ran blender again with
blender --debug --debug-all > ~/blender_debug_output.txt 2>&1
, here's the output:blender_debug_all_output.txt
And again with
blender --log "*" --log-level -1 --log-file ~/blender-log.txt
, here's that:blender-log.txt
Here's the Blender systems-info.txt:
system-info.txt
Added subscriber: @Simon_I
#87242 was marked as duplicate of this issue
#83685 was marked as duplicate of this issue
blender/blender-addons#85022 was marked as duplicate of this issue
#84366 was marked as duplicate of this issue
blender/blender-addons#84537 was marked as duplicate of this issue
#84880 was marked as duplicate of this issue
Added subscriber: @rjg
Changed status from 'Needs Triage' to: 'Needs User Info'
I can't reproduce the problem. Can you please try to start Blender with the following command:
Please also check if Blender has written a crash log in the
/tmp
directory. Upload both the crash log andblender_debug_output.txt
.Changed status from 'Needs User Info' to: 'Needs Triage'
Added subscriber: @scurest
This is likely the same as blender/blender-addons#84537 since A.N.T. Landscape imports numpy.
@scurest I can confirm that the crash seems to be related. I opened the blender python consoles and did a
import numpy
, immediately crashes. I didn't see the other report blender/blender-addons#84537 when I opened this one, but it looks very much the same, thanks for pointing that out!@Simon_I Am I reading your report correctly that the issue also occurs in the official daily builds from https://builder.blender.org/download/, labeled "portable" in the ticket?
Here are other addons which make blender crash, too:
All these addons import numpy at some point, except for Manage UI Translations, which crashes because it imports ctypes. In fact, numpy itself relies on importing ctypes lib, so this might be the actual problem
I tried running ctypes'
__init__.py
script from2.92/python/lib/python3.7/ctypes
in Blender's Python console, it crashes. I also tried all the imports from the script in Blender, it crashes when I dofrom ctypes._endian import BigEndianStructure, LittleEndianStructure
(in__init__.py
you'll find it in line 533), butctypes._endian
again does afrom ctypes import *
, so I don't really know where to look further...Yep just tried again this morning with the 2.92.0 beta downloaded from blender.org --> Download Blender --> Download Blender Experimental
Blender Snap package crash when enabling A.N.T. Landscape addonto Blender crash when enabling A.N.T. Landscape and various other addons that use ctypesThank your for looking into this. Could you please specify what processor you are using and attach your system information from Help > Save System Info, just in case this is hardware dependent?
Changed status from 'Needs Triage' to: 'Needs User Info'
@rjg I added the Info in the report. Could also provide full
lscpu
output if that's of interest. But how could the flatpak version still work if that was a hardware related issue?Here's another strange thing I've noticed: as stated above, Blender crashes when running
import ctypes
in it's Python console. If however I open Blender's Python interpreter from2.92/python/bin/python3.7m
in my operations system's terminal, I can import ctypes and numpy without having it crash or throwing an exception.Can you sprinkle some
print()
s around ctype's__init__.py
to find out exactly where it dies?@Simon_I thanks for the info. That is indeed a curious case.
Could you please open Blender and get the content of
sys.path
and also check if any of the following environment variables have been set:BLENDER_SYSTEM_PYTHON
BLENDER_SYSTEM_SCRIPTS
BLENDER_SYSTEM_DATAFILES
BLENDER_USER_SCRIPTS
Please check if there are any notable differences to the flatpak version.
@scurest I tried, but same result as before: script crashes at
from ctypes._endian import BigEndianStructure, LittleEndianStructure
I can however not debug that file any further by using prints / file writes, as it again imports ctypes itself, so_endian.py
crashes atfrom ctypes import *
which kinda brings back to where I started...@rjg notable differences in
os.environ.items()
:(note that I use Gnome on wayland, but crash also happened on X11 session)
Here's Flatpaks
sys.path()
:['/app/blender/2.91/scripts/startup', '/app/blender/2.91/scripts/modules', '/app/blender/2.91/python/lib/python37.zip', '/app/blender/2.91/python/lib/python3.7', '/app/blender/2.91/python/lib/python3.7/lib-dynload', '/app/blender/2.91/python/lib/python3.7/site-packages', '/app/blender/2.91/scripts/freestyle/modules', '/app/blender/2.91/scripts/addons/modules', '~/.var/app/org.blender.Blender/config/blender/2.91/scripts/addons/modules', '/app/blender/2.91/scripts/addons']
Here's Snaps
sys.path()
:['/snap/blender/63/2.92/scripts/startup', '/snap/blender/63/2.92/scripts/modules', '/snap/blender/63/2.92/python/lib/python37.zip', '/snap/blender/63/2.92/python/lib/python3.7', '/snap/blender/63/2.92/python/lib/python3.7/lib-dynload', '/snap/blender/63/2.92/python/lib/python3.7/site-packages', '/snap/blender/63/2.92/scripts/freestyle/modules', '/snap/blender/63/2.92/scripts/addons/modules', '~/.config/blender/2.92/scripts/addons/modules', '/snap/blender/63/2.92/scripts/addons', '/snap/blender/63/2.92/scripts/addons_contrib']
only difference seems to be the addons_contrib directory.
For the other variables you mentioned please provide information on how to get them.
When you import a module that's already been imported, you just get a reference to the module that's been executed so far, ie. everything defined up to line 533. It shouldn't actually run any more code, so this would be a very weird place to crash. Can you replace
from ctypes._endian import BigEndianStructure, LittleEndianStructure
with the contents of_endian.py
(minus thefrom ctypes import *
line) to get further?@scurest Thanks a lot. ctypes'
__init__.py
script crashes at line 551_reset_cache()
@rjg could this be related to the fact that Snap package's
os.environ.items()
does not contain any specification of cache directories?Can you check which line in the
_reset_cache
function?@scurest function
_reset_cache()
crashes at line 273CFUNCTYPE(c_int)(lambda: None)
Also note the comment that was left directly above that line:
Don't know if that refers to the line above or below the comment...
What happens if you comment it out?
When commenting that line out it runs the script without errors or crashes.
That class
CFUNCTYPE
stops at line 104:return CFunctionType
See this part of class
CFUNCTYPE
:When running the script it jumps to
except
branch, then runs through that class once, does_c_functiontyp_cache ...
and crashes when trying toreturn CFunctionType
, theprint()
s I put into the class are not printed a second time.When I run the portable Blender version with line 273 in
2.92/python/lib/python3.7/ctypes/__init__.py
commented out, I can enable all the addons mentioned above that where previously crashing Blender. I only tested real quick with A.N.TLandscape, it generates a landscape and most of it's operators seem to behave normal. Nice.Can't do it in snap however, as it's files are read only even for su.
Anyways someone with programming knowledge should try to find out why this line was needed before, I suspect just deleting that line could produce other problems...
This comment was removed by @scurest
@Simon_I That
XDG_CACHE_HOME
isn't set, shouldn't be a problem. It is supposed to default to$HOME/.cache
in that case. It is correct that you aren't finding the environment variables I've listed. It would've been potentially problematic if they would be defined and Blender would use them.@Simon_I thank you for investigating this further, we will look into this.
Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'
The code that causes issues for you exists in Python 3.7.7 but was removed by commit
e6b247c8e5 (diff-edff4421a88bdc56335a84a1e5a0ce0eafe5cd0c37dcb1aff03ff075bfb9b57c)
The line was apparently introduced as a workaround for a failing test quite a long time ago.
674e9389e9
I still don't know why this fails on your system, but judging by numerous reports about crashes in this functions this doesn't seem to be an issues isolated to Blender. From the current information I do not know whether the crash indicates a problem elsewhere or if this was just a bug in ctypes. This might need another look just to double check.
If this is indeed the cause, then we would either need to patch the Python version 3.7.7 or update to a newer version that contains the fix from upstream.
@rjg thanks for the info. Let me know if you need more information from me, otherwise I'll just hope it's as easy as removing these few lines... Have a blessed week!
@Simon_I Thank you for identifying the function that caused the problem! Do you happen to use SELinux or other security extensions?
https://bugzilla.redhat.com/show_bug.cgi?id=814391
Edit: Obviously @scurest thanks to you as well for helping debug this.
@rjg SELinux not as far as I know. This is a common Ubuntu installation. Ubuntu uses AppArmor though. The AppArmor profile for blender is in complain mode however, since Blender snaps are installed with
--classic
, so I would guess it's not enforcing any restrictions... Also running aa-notify does not register any AppArmor denials when Blender crashes.@Simon_I
Sorry, just want to make sure: I believe only the erosion operator actually uses numpy (and therefore presumably ctypes), did you try that one? You could also try exporting a cube or something to glTF since I know that uses numpy too.
@scurest Using the Landscape Erosion and exporting to glTF works now.
@Simon_I Great, thanks for checking all that stuff.
Added subscriber: @LuisYayo
Added subscribers: @skittlituted_scorpion, @Mkats13
Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'
Changed status from 'Confirmed' to: 'Needs Developer To Reproduce'
Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'
I can reproduce this with a release build of Blender 2.91.0 on Ubuntu 20.10, but not 20.04.
Added subscribers: @ideasman42, @lichtwerk
Will CC @ideasman42 here to share his wisdom.
We can patch the Python that's distributed with Blender, although I'm not keen on this as a precedent.
Note that we could update this at run-time via monkey-patching (not especially nice either).
Unfortunately this is being kept for the 3.7 series (as it's still in 3.7.9).
Judging by #83246, it's possible we'll upgrade Python, although we didn't yet make a decision on this.
So does that mean that for now, we know there's a bug, it'll be fixed when python is upgraded ?
Added subscriber: @dr.sybren
Which Python version fixes this? I mean, upgrading to 3.7.9 is quite different from upgrading to 3.10-alpha.
@dr.sybren Based on the tags of the commit, this appears to be in 3.8.0 and later.
Please note that I haven't investigated (yet) why it doesn't crash when using Flatpak.
Added subscriber: @tomb
Added subscriber: @luifernandi
Blender crash when enabling A.N.T. Landscape and various other addons that use ctypesto Crash using 'ctypes' (fixed in Python >= 3.8), causes crashes in A.N.T. Landscape and various other addonsWith the new Blender 2.93.0 Alpha export of GLTF works fine. Many thanks!
@tomb That is a bit strange, we didn't patch ctypes or switch the Python version yet. Are you using one of the daily builds from https://builder.blender.org/download/ ?
Yes now I'm using the daily builds.
I reinstalled python from the console. Then I launched the newest Blender 2.93.0 Alpha daily build, downloaded by me yesterday. I don't know, but it seems installed python have nothing to do with it, because older versions of Blender keep crashing when trying to export gltf. Blender 2.93.0 Alpha works fine for me.
Added subscribers: @carlf, @JulienDuroure, @ry167
@tomb Can't confirm, exporting the default cube to gltf still crashes for me when using the latest 2.93 alpha
@Simon_I @rjg Yes, right, sorry for the confusion, still crashes. I don't know how I managed to export 2 days ago, but really without crash. Anyway I see export window, before I didn't see even the window.
Changed status from 'Confirmed' to: 'Resolved'
Closing, as Blender has moved to Python 3.9.
Added subscriber: @vm