save_as_mainfile will crash if context has no screen #93949
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
FBX
Interest
Freestyle
Interest
Geometry Nodes
Interest
glTF
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 & 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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & 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
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#93949
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
Windows 10
GTX 970
Blender Version
Broken: 3.0
Worked: 2.93
Short description of error
using python, loading a template.blend file and saving as a new.blend file will crash blender if a camera is present in the template.blend file.
Exact steps for others to reproduce the error
In script editor execute:
With factory startup file, this will cause crash - NULL dereference in
BKE_screen_find_big_area()
,screen
wasNULL
Added subscriber: @spiraloid-3
#95188 was marked as duplicate of this issue
#93950 was marked as duplicate of this issue
Added subscriber: @iss
Not sure if this is different report than #93950, but if there are different steps, please provide them.
Different issue then #93950.
(see last comment)
Steps to reproduce, Install the addon attached to my previous post and click “crash me” in the file menu.
write a python script to load a blend file containing a camera and then save out a new blend file.
this is essentially all my addon does.
if you look at my python, I commented the source of the crash. (it has something to do with loading a .blend file containing a camera and saving again)
I spent quite a bit of time finding the exact steps to reproduce this crash.
Added subscriber: @michael64
Thanks @spiraloid-3 for the detailed description, I could reproduce the crash, find a fix for future Blender versions and a workaround for you to get your add-on working with Blender 3.0.
For your workaround you have to circumvent the automatic thumbnail generation that was introduced in
4fa0bbb5
.This can be done for example like this
Because thumbnails are only automatically generated from the main thread, calling bpy.ops.wm.save_as_mainfile from another thread should also work but the previous workaround seems simpler.
Also if the scene already had a thumbnail it would not be regenerated in save_as_mainfile.
Now for the cause of the crash for the Blender developers.
The automatic thumbnail generation calls BKE_screen_find_big_area in wm_files.c: (BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0) != NULL)
This function in screen.c references screen->areabase before checking if screen is NULL which can be the case when called from a Python add-on.
This dereferencing screen->areabase crashes the Blender process.
I would propose a three-line addition that returns NULL if a NULL screen was passed in as the logic that NULL can be returned seems to be already expected by the callers:
I have not looked at the difference to #93950 but maybe the same error could be triggered in two different ways.
That scene->camera != NULL short circuits the call to BKE_screen_find_big_area in case of a missing camera also explains why crashmenot.blend does not crash.
Thanks so much @michael64, Much appreciated.
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @Harley
CC @Harley
Added subscribers: @chemicalcrux, @Raimund58
Blener crash w python save as".to save_as_mainfile will crash if context has no screenThis issue was referenced by
e53f3954a4
This issue was referenced by
644eb68524
Changed status from 'Confirmed' to: 'Resolved'
Added subscriber: @Lendo
FYI, I'm getting a similar preview error if the asset browser is visible.
I've resorted to
in the interrum.
@spiraloid-3 Please open new report and provide information as described in template.