Python segfault or incorrect select_set() #94204

Open
opened 2021-12-17 21:05:05 +01:00 by Andrew Hodel · 7 comments

System Information
Operating system: MacOS 12.01
Graphics card: Intel MacBook Pro

Blender Version
Broken: 2.83.9, 3.0.0 and 3.1.0 Alpha, branch: master, commit date: 2021-12-17 14:21, hash: c0d96ca9a5

Short description of error
Segmentation Fault happens or select_set is applied to the wrong object.

Exact steps for others to reproduce the error

  • Based on the default startup file
  • Run the code provided below (two Font objects will be created)
  • Select all objects
  • Run this code again
lines=12, lang=py
import bpy

for n in bpy.data.objects:
    try:
        l = n['clearable']
    except:
        print("no clear")
    else:
        print("deleting", n.name)
        n.select_set(True)
        bpy.ops.object.delete() 

# add text
font_curve = bpy.data.curves.new(type="FONT", name="Font Curve")
font_curve.body = '2.44%'
font_obj = bpy.data.objects.new(name="Font Object", object_data=font_curve)
font_obj.rotation_euler = [1.55,0,0]
font_obj.location = [10,0,2]
font_obj.scale = [.7,.7,.7]
font_obj['clearable'] = True
# move the object to the collection, called link but taught as "viewed as part of" first via UI
bpy.data.collections['Collection'].objects.link(font_obj)
print(font_obj.scale, font_obj.location)

font_curve = bpy.data.curves.new(type="FONT", name="Font Curve")
font_curve.body = '2.44%'
font_obj = bpy.data.objects.new(name="Font Object", object_data=font_curve)
font_obj.rotation_euler = [1.55,0,0]
font_obj.location = [10,0,2]
font_obj.scale = [.7,.7,.7]
# move the object to the collection, called link but taught as "viewed as part of" first via UI
bpy.data.collections['Collection'].objects.link(font_obj)
print(font_obj.scale, font_obj.location)
**System Information** Operating system: MacOS 12.01 Graphics card: Intel MacBook Pro **Blender Version** Broken: 2.83.9, 3.0.0 and 3.1.0 Alpha, branch: master, commit date: 2021-12-17 14:21, hash: `c0d96ca9a5` **Short description of error** Segmentation Fault happens or select_set is applied to the wrong object. **Exact steps for others to reproduce the error** - Based on the default startup file - Run the code provided below (two Font objects will be created) - Select all objects - Run this code again ``` lines=12, lang=py import bpy for n in bpy.data.objects: try: l = n['clearable'] except: print("no clear") else: print("deleting", n.name) n.select_set(True) bpy.ops.object.delete() # add text font_curve = bpy.data.curves.new(type="FONT", name="Font Curve") font_curve.body = '2.44%' font_obj = bpy.data.objects.new(name="Font Object", object_data=font_curve) font_obj.rotation_euler = [1.55,0,0] font_obj.location = [10,0,2] font_obj.scale = [.7,.7,.7] font_obj['clearable'] = True # move the object to the collection, called link but taught as "viewed as part of" first via UI bpy.data.collections['Collection'].objects.link(font_obj) print(font_obj.scale, font_obj.location) font_curve = bpy.data.curves.new(type="FONT", name="Font Curve") font_curve.body = '2.44%' font_obj = bpy.data.objects.new(name="Font Object", object_data=font_curve) font_obj.rotation_euler = [1.55,0,0] font_obj.location = [10,0,2] font_obj.scale = [.7,.7,.7] # move the object to the collection, called link but taught as "viewed as part of" first via UI bpy.data.collections['Collection'].objects.link(font_obj) print(font_obj.scale, font_obj.location) ```
Author

Added subscriber: @andrewhodel

Added subscriber: @andrewhodel

Added subscribers: @ankitm, @iss

Added subscribers: @ankitm, @iss

Can't reproduce here on windows. @ankitm can you check?

Can't reproduce here on windows. @ankitm can you check?

Added subscriber: @jenkm

Added subscriber: @jenkm

Operating system: macOS-11.6-x86_64-i386-64bit 64 Bits
Graphics card: AMD Radeon Pro 455 OpenGL Engine ATI Technologies Inc. 4.1 ATI-4.6.20

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   org.blenderfoundation.blender 	0x00000001101871a5 _PyObject_GC_UNTRACK_impl + 8 (pycore_object.h:73) [inlined]
1   org.blenderfoundation.blender 	0x00000001101871a5 PyObject_GC_UnTrack + 21 (gcmodule.c:2212)
2   org.blenderfoundation.blender 	0x0000000110086f7e subtype_dealloc + 174 (typeobject.c:1259)
3   org.blenderfoundation.blender 	0x00000001100617e0 _Py_DECREF + 8 (object.h:430) [inlined]
4   org.blenderfoundation.blender 	0x00000001100617e0 _Py_XDECREF + 8 (object.h:497) [inlined]
5   org.blenderfoundation.blender 	0x00000001100617e0 insertdict + 560 (dictobject.c:1123)
6   org.blenderfoundation.blender 	0x0000000110118f30 _PyEval_EvalFrameDefault + 12288 (ceval.c:2355)
7   org.blenderfoundation.blender 	0x0000000110120fad _PyEval_EvalFrame + 18 (pycore_ceval.h:40) [inlined]
8   org.blenderfoundation.blender 	0x0000000110120fad _PyEval_EvalCode + 3245 (ceval.c:4327)
9   org.blenderfoundation.blender 	0x0000000110115e60 _PyEval_EvalCodeWithName + 51 (ceval.c:4359) [inlined]
10  org.blenderfoundation.blender 	0x0000000110115e60 PyEval_EvalCodeEx + 51 (ceval.c:4375) [inlined]
11  org.blenderfoundation.blender 	0x0000000110115e60 PyEval_EvalCode + 64 (ceval.c:826)
12  org.blenderfoundation.blender 	0x000000010829fdc6 python_script_exec + 582
13  org.blenderfoundation.blender 	0x0000000108978fe0 text_run_script + 64
14  org.blenderfoundation.blender 	0x0000000107d10b68 wm_operator_invoke + 424
15  org.blenderfoundation.blender 	0x0000000107d10933 wm_operator_call_internal + 531
16  org.blenderfoundation.blender 	0x0000000107d11c13 WM_operator_name_call_ptr_with_depends_on_cursor + 163
17  org.blenderfoundation.blender 	0x0000000108814e5a ui_apply_but_funcs_after + 282
18  org.blenderfoundation.blender 	0x0000000108811370 ui_handler_region_menu + 464
19  org.blenderfoundation.blender 	0x0000000107d13cb1 wm_handlers_do_intern + 945
20  org.blenderfoundation.blender 	0x0000000107d135c4 wm_handlers_do + 52
21  org.blenderfoundation.blender 	0x0000000107d12a43 wm_event_do_handlers + 1555
22  org.blenderfoundation.blender 	0x0000000107d09eb0 WM_main + 32
23  org.blenderfoundation.blender 	0x0000000107764f0e main + 878
24  libdyld.dylib                 	0x00007fff2038cf3d start + 1
Operating system: macOS-11.6-x86_64-i386-64bit 64 Bits Graphics card: AMD Radeon Pro 455 OpenGL Engine ATI Technologies Inc. 4.1 ATI-4.6.20 ``` Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 org.blenderfoundation.blender 0x00000001101871a5 _PyObject_GC_UNTRACK_impl + 8 (pycore_object.h:73) [inlined] 1 org.blenderfoundation.blender 0x00000001101871a5 PyObject_GC_UnTrack + 21 (gcmodule.c:2212) 2 org.blenderfoundation.blender 0x0000000110086f7e subtype_dealloc + 174 (typeobject.c:1259) 3 org.blenderfoundation.blender 0x00000001100617e0 _Py_DECREF + 8 (object.h:430) [inlined] 4 org.blenderfoundation.blender 0x00000001100617e0 _Py_XDECREF + 8 (object.h:497) [inlined] 5 org.blenderfoundation.blender 0x00000001100617e0 insertdict + 560 (dictobject.c:1123) 6 org.blenderfoundation.blender 0x0000000110118f30 _PyEval_EvalFrameDefault + 12288 (ceval.c:2355) 7 org.blenderfoundation.blender 0x0000000110120fad _PyEval_EvalFrame + 18 (pycore_ceval.h:40) [inlined] 8 org.blenderfoundation.blender 0x0000000110120fad _PyEval_EvalCode + 3245 (ceval.c:4327) 9 org.blenderfoundation.blender 0x0000000110115e60 _PyEval_EvalCodeWithName + 51 (ceval.c:4359) [inlined] 10 org.blenderfoundation.blender 0x0000000110115e60 PyEval_EvalCodeEx + 51 (ceval.c:4375) [inlined] 11 org.blenderfoundation.blender 0x0000000110115e60 PyEval_EvalCode + 64 (ceval.c:826) 12 org.blenderfoundation.blender 0x000000010829fdc6 python_script_exec + 582 13 org.blenderfoundation.blender 0x0000000108978fe0 text_run_script + 64 14 org.blenderfoundation.blender 0x0000000107d10b68 wm_operator_invoke + 424 15 org.blenderfoundation.blender 0x0000000107d10933 wm_operator_call_internal + 531 16 org.blenderfoundation.blender 0x0000000107d11c13 WM_operator_name_call_ptr_with_depends_on_cursor + 163 17 org.blenderfoundation.blender 0x0000000108814e5a ui_apply_but_funcs_after + 282 18 org.blenderfoundation.blender 0x0000000108811370 ui_handler_region_menu + 464 19 org.blenderfoundation.blender 0x0000000107d13cb1 wm_handlers_do_intern + 945 20 org.blenderfoundation.blender 0x0000000107d135c4 wm_handlers_do + 52 21 org.blenderfoundation.blender 0x0000000107d12a43 wm_event_do_handlers + 1555 22 org.blenderfoundation.blender 0x0000000107d09eb0 WM_main + 32 23 org.blenderfoundation.blender 0x0000000107764f0e main + 878 24 libdyld.dylib 0x00007fff2038cf3d start + 1 ```

I can now reproduce crash with updated steps, but I get different trace

pyrna was freed or uninitialized

>	blender.exe!pyrna_struct_CreatePyObject(PointerRNA * ptr) Line 7419	C

 	blender.exe!pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA * self) Line 7107	C
 	python39_d.dll!_PyEval_EvalFrameDefault(_ts * tstate, _frame * f, int throwflag) Line 3307	C
 	[Inline Frame] python39_d.dll!_PyEval_EvalFrame(_ts *) Line 40	C
 	python39_d.dll!_PyEval_EvalCode(_ts * tstate, _object * _co, _object * globals, _object * locals, _object * const * args, __int64 argcount, _object * const * kwnames, _object * const * kwargs, __int64 kwcount, int kwstep, _object * const * defs, __int64 defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4327	C
 	python39_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * const * args, __int64 argcount, _object * const * kwnames, _object * const * kwargs, __int64 kwcount, int kwstep, _object * const * defs, __int64 defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4366	C
 	python39_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * const * args, int argcount, _object * const * kws, int kwcount, _object * const * defs, int defcount, _object * kwdefs, _object * closure) Line 4382	C
 	python39_d.dll!PyEval_EvalCode(_object * co, _object * globals, _object * locals) Line 832	C
 	blender.exe!python_script_exec(bContext * C, const unsigned char * fn, Text * text, ReportList * reports, const bool do_jump) Line 135	C
 	blender.exe!BPY_run_text(bContext * C, Text * text, ReportList * reports, const bool do_jump) Line 231	C
 	blender.exe!text_run_script(bContext * C, ReportList * reports) Line 789	C
 	blender.exe!text_run_script_exec(bContext * C, wmOperator * op) Line 830	C
 	blender.exe!wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Line 1325	C
 	blender.exe!wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const wmOperatorCallContext context, const bool poll_only, wmEvent * event) Line 1520	C
 	blender.exe!WM_operator_name_call_ptr(bContext * C, wmOperatorType * ot, wmOperatorCallContext context, PointerRNA * properties) Line 1568	C
 	blender.exe!WM_operator_name_call_ptr_with_depends_on_cursor(bContext * C, wmOperatorType * ot, wmOperatorCallContext opcontext, PointerRNA * properties, const unsigned char * drawstr) Line 1756	C
 	blender.exe!ui_apply_but_funcs_after(bContext * C) Line 1028	C
 	blender.exe!ui_handler_region_menu(bContext * C, const wmEvent * event, void * UNUSED_userdata) Line 11381	C
 	blender.exe!wm_handler_ui_call(bContext * C, wmEventHandler_UI * handler, const wmEvent * event, int always_pass) Line 688	C
 	blender.exe!wm_handlers_do_intern(bContext * C, wmWindow * win, wmEvent * event, ListBase * handlers) Line 3016	C
 	blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 3130	C
 	blender.exe!wm_event_do_handlers(bContext * C) Line 3618	C
 	blender.exe!WM_main(bContext * C) Line 642	C
 	blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 565	C
 	[External Code]	
I can now reproduce crash with updated steps, but I get different trace `pyrna` was freed or uninitialized ``` > blender.exe!pyrna_struct_CreatePyObject(PointerRNA * ptr) Line 7419 C blender.exe!pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA * self) Line 7107 C python39_d.dll!_PyEval_EvalFrameDefault(_ts * tstate, _frame * f, int throwflag) Line 3307 C [Inline Frame] python39_d.dll!_PyEval_EvalFrame(_ts *) Line 40 C python39_d.dll!_PyEval_EvalCode(_ts * tstate, _object * _co, _object * globals, _object * locals, _object * const * args, __int64 argcount, _object * const * kwnames, _object * const * kwargs, __int64 kwcount, int kwstep, _object * const * defs, __int64 defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4327 C python39_d.dll!_PyEval_EvalCodeWithName(_object * _co, _object * globals, _object * locals, _object * const * args, __int64 argcount, _object * const * kwnames, _object * const * kwargs, __int64 kwcount, int kwstep, _object * const * defs, __int64 defcount, _object * kwdefs, _object * closure, _object * name, _object * qualname) Line 4366 C python39_d.dll!PyEval_EvalCodeEx(_object * _co, _object * globals, _object * locals, _object * const * args, int argcount, _object * const * kws, int kwcount, _object * const * defs, int defcount, _object * kwdefs, _object * closure) Line 4382 C python39_d.dll!PyEval_EvalCode(_object * co, _object * globals, _object * locals) Line 832 C blender.exe!python_script_exec(bContext * C, const unsigned char * fn, Text * text, ReportList * reports, const bool do_jump) Line 135 C blender.exe!BPY_run_text(bContext * C, Text * text, ReportList * reports, const bool do_jump) Line 231 C blender.exe!text_run_script(bContext * C, ReportList * reports) Line 789 C blender.exe!text_run_script_exec(bContext * C, wmOperator * op) Line 830 C blender.exe!wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Line 1325 C blender.exe!wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const wmOperatorCallContext context, const bool poll_only, wmEvent * event) Line 1520 C blender.exe!WM_operator_name_call_ptr(bContext * C, wmOperatorType * ot, wmOperatorCallContext context, PointerRNA * properties) Line 1568 C blender.exe!WM_operator_name_call_ptr_with_depends_on_cursor(bContext * C, wmOperatorType * ot, wmOperatorCallContext opcontext, PointerRNA * properties, const unsigned char * drawstr) Line 1756 C blender.exe!ui_apply_but_funcs_after(bContext * C) Line 1028 C blender.exe!ui_handler_region_menu(bContext * C, const wmEvent * event, void * UNUSED_userdata) Line 11381 C blender.exe!wm_handler_ui_call(bContext * C, wmEventHandler_UI * handler, const wmEvent * event, int always_pass) Line 688 C blender.exe!wm_handlers_do_intern(bContext * C, wmWindow * win, wmEvent * event, ListBase * handlers) Line 3016 C blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 3130 C blender.exe!wm_event_do_handlers(bContext * C) Line 3618 C blender.exe!WM_main(bContext * C) Line 642 C blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 565 C [External Code] ```

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Philipp Oeser removed the
Interest
Python API
label 2023-02-10 09:04:28 +01: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
3 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#94204
No description provided.