EXCEPTION_ACCESS_VIOLATION crash using python API - accessing vertex colors / assigning uv #112432

Closed
opened 2023-09-16 08:22:00 +02:00 by Andrej · 2 comments
Contributor

Blender 3.6.2, Windows 11
I've met some crash running code from Python API and managed to narrow it down to the snippet below.

Way to reproduce:

  1. Open blender default scene, select cube
  2. Run the snippet below from text editor. Might need to run it multiple times (sometimes I get it from the first run, sometimes it crashes after 5-10 times)
  3. Try to comment one of the lines vertex_colors = or uv_layer[i].uv = and crash will disappear.
import bpy
from mathutils import Vector

def updateMesh(context):
    mesh = context.object.data
    uv_layer = mesh.uv_layers.active.data
    
    # try to comment this line
    vertex_colors = mesh.vertex_colors.new().data
    
    for i in range(len(mesh.loops)):
        pass
        # or try to comment this line
        uv_layer[i].uv = Vector((1,1)).xy

updateMesh(bpy.context)
Blender 3.6.2, Windows 11 I've met some crash running code from Python API and managed to narrow it down to the snippet below. Way to reproduce: 1) Open blender default scene, select cube 2) Run the snippet below from text editor. Might need to run it multiple times (sometimes I get it from the first run, sometimes it crashes after 5-10 times) 3) Try to comment one of the lines `vertex_colors = ` or `uv_layer[i].uv = ` and crash will disappear. ```python import bpy from mathutils import Vector def updateMesh(context): mesh = context.object.data uv_layer = mesh.uv_layers.active.data # try to comment this line vertex_colors = mesh.vertex_colors.new().data for i in range(len(mesh.loops)): pass # or try to comment this line uv_layer[i].uv = Vector((1,1)).xy updateMesh(bpy.context) ```
Andrej added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-09-16 08:22:01 +02:00
Andrej changed title from EXCEPTION_ACCESS_VIOLATION crash using python API - accessing vertex colors / assigning ui to EXCEPTION_ACCESS_VIOLATION crash using python API - accessing vertex colors / assigning uv 2023-09-16 08:22:10 +02:00

This is actually the same as #107500. Adding new vertex_colors will cause existing references to uv_layers (or similar) to become invalidated. Feel free to subscribe to the other task for updates. However, in general, it sounds like the best course of action is to reference the particular data layers each time it needs to be used and not cache them.

This is actually the same as #107500. Adding new vertex_colors will cause existing references to uv_layers (or similar) to become invalidated. Feel free to subscribe to the other task for updates. However, in general, it sounds like the best course of action is to reference the particular data layers each time it needs to be used and not cache them.
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-09-16 08:40:06 +02:00
Jesse Yurkovich added
Status
Duplicate
and removed
Status
Archived
labels 2023-09-16 08:40:14 +02:00
Author
Contributor

Can confirm that creating vertex color first and only then accessing uv layer helped.

import bpy
from mathutils import Vector

def updateMesh(context):
    mesh = context.object.data
    
    vertex_colors = mesh.vertex_colors.new().data
    uv_layer = mesh.uv_layers.active.data
    
    for i in range(len(mesh.loops)):
        uv_layer[i].uv = Vector((1,1)).xy

updateMesh(bpy.context)
Can confirm that creating vertex color first and only then accessing uv layer helped. ```python import bpy from mathutils import Vector def updateMesh(context): mesh = context.object.data vertex_colors = mesh.vertex_colors.new().data uv_layer = mesh.uv_layers.active.data for i in range(len(mesh.loops)): uv_layer[i].uv = Vector((1,1)).xy updateMesh(bpy.context) ```
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#112432
No description provided.