Crash when setting asset preview image from python (ASAN heap-use-after-free in render_preview.c) #91197
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#91197
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: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 466.47
Blender Version
Broken: version: 3.0.0 Alpha, branch: master (modified), commit date: 2021-09-02 14:26, hash:
6fc92b296f
Short description of error
This is an intermittent crash when running the script in the text editor. Happens after a programmatic render, setting object as asset and assigning an image file to that asset.
Exact steps for others to reproduce the error
It may work and mark the cube as an asset and assign it a preview, OR it may crash Blender.
Sometimes it happens on the first run, other times, it takes several runs (5-10) on different cubes that have not yet been marked as assets.
Other times, I've had to duplicate the pile of cubes and select a new one and re-run the script.
[Simplified ASAN repro]
#91197-simplified.blend
[Previous Crashing File and ASAN report]
#91197-crash.blend
#91197-asan.txt
[Original Data below]
crash.blend
**Stack Track From Crash
Added subscriber: @guitargeek
Python Script Crashes Blender - May be related to Setting Asset Preview Imageto Crash when setting asset preview image from python (ASAN heap-use-after-free in render_preview.c)Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @deadpin
I updated the crash.blend file above since it wouldn't run by itself. It was still trying to access your
scene.asset_snapshot
variable.In any case, I can reproduce the crash the first time with ASAN. It almost looks like the default preview image job (triggered asynchronously by
asset_mark
) is overlapping with the custom preview image operation.I attached the full ASAN report above.
The current version of the script does not crash because I removed the need to switch editor types:
https://github.com/johnnygizmo/asset_snapshot
Added subscriber: @dr.sybren
Changed status from 'Confirmed' to: 'Needs User Info'
Please take some time to minimize the script, so that every line that is there is actually required to reproduce the crash. That'll help a lot in figuring out what's going wrong.
Changed status from 'Needs User Info' to: 'Confirmed'
Modified the description to include a further simplified repro (
#91197-simplified.blend
) as I'm still getting ASAN failures here. The issue is primarily because of the interaction betweenasset_mark
andlib_id_load_custom_preview
trampling over each other.The
asset_mark
api is very precarious. It starts an async icon preview job for which the python caller has no way of waiting or knowing when it finishes.But even if you try to somehow "wait", (by sleeping) in the python script, this still fails due to how the single-thread python execution happens. The "end" of the icon_preview job is not permitted to run while the python script is executing it looks like.
This will probably be a common pattern to do in general. Script authors will want to automate the marking and setting of custom preview image for their users.
This is good feedback, thanks.
Idea to fix this issue is to add a
render_preview:bool = True
parameter to theID.asset_mark
function.When set to False the preview render will not be performed.
This issue was referenced by
1c5722ba07
Changed status from 'Confirmed' to: 'Resolved'
Since Jeroen's comment the ideas changed a bit. Instead of passing a boolean, the two operations performed by that
ID.asset_mark()
function have been separated.ID.asset_mark()
now only marks a datablock as asset, and ``ID.asset_generate_preview()` should be called to actually generate the previews.