Crash after executing the script #110450

Closed
opened 2023-07-25 08:58:46 +02:00 by William Gacquer · 9 comments

System Information
Operating system: Windows-10-10.0.22621-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3080 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 535.98

Blender Version
Broken: version: 3.6.1 Release Candidate, branch: blender-v3.6-release, commit date: 2023-07-16 02:43, hash: edc1a09966a7
Worked: (newest version of Blender that worked as expected)

Short description of error
Application crashes when clicking on the script run button

Exact steps for others to reproduce the error
1/ launch Blender
2/ click on "Scripting" tab; click "New"
3/ paste the following chatgpt generated script and run it:

import bpy
from math import sqrt, sin, cos

# Define the vertices of the tetrahedrons
vertices1 = [
    (1, 1, 1),
    (-1, -1, 1),
    (-1, 1, -1),
    (1, -1, -1)
]

vertices2 = [
    (1, -1, -1),
    (-1, 1, -1),
    (-1, -1, 1),
    (1, 1, 1)
]

# Define the faces of the tetrahedrons
faces1 = [
    (0, 1, 2),
    (0, 2, 3),
    (0, 3, 1),
    (1, 3, 2)
]

faces2 = [
    (0, 1, 2),
    (0, 2, 3),
    (0, 3, 1),
    (1, 3, 2)
]

# Create new meshes and objects
mesh1 = bpy.data.meshes.new("Tetrahedron1")
obj1 = bpy.data.objects.new("Tetrahedron1", mesh1)

mesh2 = bpy.data.meshes.new("Tetrahedron2")
obj2 = bpy.data.objects.new("Tetrahedron2", mesh2)

# Set the object locations and scene context
obj1.location = (-2, 0, 0)
bpy.context.scene.collection.objects.link(obj1)

obj2.location = (2, 0, 0)
bpy.context.scene.collection.objects.link(obj2)

# Create the vertices and faces of the meshes
mesh1.from_pydata(vertices1, [], faces1)
mesh1.update(calc_edges=True)

mesh2.from_pydata(vertices2, [], faces2)
mesh2.update(calc_edges=True)

# Hinge the tetrahedrons together by one edge
edge1 = mesh1.edges[0]
edge2 = mesh2.edges[2]

bpy.ops.object.select_all(action='DESELECT')
obj1.select_set(True)
obj2.select_set(True)

bpy.context.view_layer.objects.active = obj2
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
edge2.select = True
bpy.ops.mesh.edge_face_add()
bpy.ops.object.mode_set(mode='OBJECT')

# Add an armature to the tetrahedrons
bpy.ops.object.armature_add()
armature = bpy.context.object
armature.name = "HingeArmature"
armature.location = (0, 0, 0)

# Add bones to the armature
bpy.ops.object.mode_set(mode='EDIT')
bone1 = armature.data.edit_bones.new('Bone1')
bone1.head = (0, 0, 0)
bone1.tail = (-2, 0, 0)
bone1.use_deform = False

bone2 = armature.data.edit_bones.new('Bone2')
bone2.head = (0, 0, 0)
bone2.tail = (2, 0, 0)
bone2.use_deform = False

bpy.ops.object.mode_set(mode='OBJECT')

# Parent the tetrahedrons to the armature
obj1.parent = armature
obj1.parent_type = 'BONE'
obj1.parent_bone = 'Bone1'

obj2.parent = armature
obj2.parent_type = 'BONE'
obj2.parent_bone = 'Bone2'

# Animate the hinge
frames = 30

for frame in range(frames):
    bpy.context.scene.frame_set(frame)

    angle = frame / frames * 2 * 3.14159265

    bone1.tail = (-2 * cos(angle), 0, -2 * sin(angle))
    bone2.tail = (2 * cos(angle), 0, 2 * sin(angle))

    bone1.keyframe_insert(data_path='tail')
    bone2.keyframe_insert(data_path='tail')
**System Information** Operating system: Windows-10-10.0.22621-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3080 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 535.98 **Blender Version** Broken: version: 3.6.1 Release Candidate, branch: blender-v3.6-release, commit date: 2023-07-16 02:43, hash: `edc1a09966a7` Worked: (newest version of Blender that worked as expected) **Short description of error** Application crashes when clicking on the script run button **Exact steps for others to reproduce the error** 1/ launch Blender 2/ click on "Scripting" tab; click "New" 3/ paste the following chatgpt generated script and run it: ``` import bpy from math import sqrt, sin, cos # Define the vertices of the tetrahedrons vertices1 = [ (1, 1, 1), (-1, -1, 1), (-1, 1, -1), (1, -1, -1) ] vertices2 = [ (1, -1, -1), (-1, 1, -1), (-1, -1, 1), (1, 1, 1) ] # Define the faces of the tetrahedrons faces1 = [ (0, 1, 2), (0, 2, 3), (0, 3, 1), (1, 3, 2) ] faces2 = [ (0, 1, 2), (0, 2, 3), (0, 3, 1), (1, 3, 2) ] # Create new meshes and objects mesh1 = bpy.data.meshes.new("Tetrahedron1") obj1 = bpy.data.objects.new("Tetrahedron1", mesh1) mesh2 = bpy.data.meshes.new("Tetrahedron2") obj2 = bpy.data.objects.new("Tetrahedron2", mesh2) # Set the object locations and scene context obj1.location = (-2, 0, 0) bpy.context.scene.collection.objects.link(obj1) obj2.location = (2, 0, 0) bpy.context.scene.collection.objects.link(obj2) # Create the vertices and faces of the meshes mesh1.from_pydata(vertices1, [], faces1) mesh1.update(calc_edges=True) mesh2.from_pydata(vertices2, [], faces2) mesh2.update(calc_edges=True) # Hinge the tetrahedrons together by one edge edge1 = mesh1.edges[0] edge2 = mesh2.edges[2] bpy.ops.object.select_all(action='DESELECT') obj1.select_set(True) obj2.select_set(True) bpy.context.view_layer.objects.active = obj2 bpy.ops.object.mode_set(mode='EDIT') bpy.ops.mesh.select_all(action='DESELECT') edge2.select = True bpy.ops.mesh.edge_face_add() bpy.ops.object.mode_set(mode='OBJECT') # Add an armature to the tetrahedrons bpy.ops.object.armature_add() armature = bpy.context.object armature.name = "HingeArmature" armature.location = (0, 0, 0) # Add bones to the armature bpy.ops.object.mode_set(mode='EDIT') bone1 = armature.data.edit_bones.new('Bone1') bone1.head = (0, 0, 0) bone1.tail = (-2, 0, 0) bone1.use_deform = False bone2 = armature.data.edit_bones.new('Bone2') bone2.head = (0, 0, 0) bone2.tail = (2, 0, 0) bone2.use_deform = False bpy.ops.object.mode_set(mode='OBJECT') # Parent the tetrahedrons to the armature obj1.parent = armature obj1.parent_type = 'BONE' obj1.parent_bone = 'Bone1' obj2.parent = armature obj2.parent_type = 'BONE' obj2.parent_bone = 'Bone2' # Animate the hinge frames = 30 for frame in range(frames): bpy.context.scene.frame_set(frame) angle = frame / frames * 2 * 3.14159265 bone1.tail = (-2 * cos(angle), 0, -2 * sin(angle)) bone2.tail = (2 * cos(angle), 0, 2 * sin(angle)) bone1.keyframe_insert(data_path='tail') bone2.keyframe_insert(data_path='tail') ```
William Gacquer added the
Type
Report
Status
Needs Triage
Priority
Normal
labels 2023-07-25 08:58:47 +02:00
Member

HI, it crashed when assigning scalar value to bone.tail which is a vector.

ChatGPT is not a good way of generating usable code. Please try following the python documentation and program your feature.

HI, it crashed when assigning scalar value to `bone.tail` which is a vector. ChatGPT is not a good way of generating usable code. Please try following the python documentation and program your feature.
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-07-25 09:18:56 +02:00

I beg your pardon but I did not want help to fix the code. I definitely know that the code is wrong.
I report the fact that Blender crashes instead of raising an exception. This is the bug. No script should be able to kill Blender.
Sorry for the misunderstanding implied by a not detailed enough bug report.

I beg your pardon but I did not want help to fix the code. I definitely know that the code is wrong. I report the fact that Blender crashes instead of raising an exception. This is the bug. No script should be able to kill Blender. Sorry for the misunderstanding implied by a not detailed enough bug report.
Blender Bot added
Status
Needs Triage
and removed
Status
Archived
labels 2023-07-25 10:04:03 +02:00
Member

I ran the script with vector input but it still crashes. Need to check further

I ran the script with vector input but it still crashes. Need to check further

@PratikPB2123 On zero frame?

@PratikPB2123 On zero frame?
Member

that just skips the for loop.
Crash is probably because bone->parent points to garbage memory.

that just skips the for loop. Crash is probably because bone->parent points to garbage memory.
Member

I see, crash is because edit bone is accessed (refer: rna_Armature_editbone_transform_update) in object mode.
Just remove this line from python script: bpy.ops.object.mode_set(mode='OBJECT') (edit: from line 88)

I see, crash is because edit bone is accessed (refer: `rna_Armature_editbone_transform_update`) in object mode. Just remove this line from python script: `bpy.ops.object.mode_set(mode='OBJECT')` (edit: from line 88)
Member

This is the bug. No script should be able to kill Blender.

python scripts do result in crash, not necessary they are bug always.
@dr.sybren , can you check? Would you consider this a bug?

> This is the bug. No script should be able to kill Blender. python scripts do result in crash, not necessary they are bug always. @dr.sybren , can you check? Would you consider this a bug?
Pratik Borhade changed title from A method to crash Blender with a ChatGPT generated script to Crash after executing the script 2023-07-25 11:58:54 +02:00

I beg your pardon but I did not want help to fix the code. I definitely know that the code is wrong.

Please don't use known-wrong code to report a bug against Blender.

Minimize the code, such that every line is essential for reproducing the crash. Newlines for spacing are ok, but every line of actual code should be important. If it can be removed and still result in the crash, remove it.

I report the fact that Blender crashes instead of raising an exception. This is the bug. No script should be able to kill Blender.

This is a misconception. It is very easy to crash Blender or even grind your computer to a halt. Just keep generating enough objects in a loop and it'll eventually run out of memory.

> I beg your pardon but I did not want help to fix the code. I definitely know that the code is wrong. Please don't use known-wrong code to report a bug against Blender. Minimize the code, such that every line is essential for reproducing the crash. Newlines for spacing are ok, but every line of actual code should be important. If it can be removed and still result in the crash, remove it. > I report the fact that Blender crashes instead of raising an exception. This is the bug. No script should be able to kill Blender. This is a misconception. It is very easy to crash Blender or even grind your computer to a halt. Just keep generating enough objects in a loop and it'll eventually run out of memory.
Sybren A. Stüvel added
Status
Needs Information from User
and removed
Status
Needs Info from Developers
labels 2023-10-10 11:02:57 +02:00
Member

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed.

Thanks again for the report. If the problem persists please open a new report with the required information.

No activity for more than a week. As per the tracker policy we assume the issue is gone and can be closed. Thanks again for the report. If the problem persists please open a new report with the required information.
Blender Bot added
Status
Archived
and removed
Status
Needs Information from User
labels 2023-10-23 09:03:50 +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
5 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#110450
No description provided.