bl_description = None triggers segfault on register. #86983

Closed
opened 2021-03-27 20:08:11 +01:00 by Will · 7 comments

System Information
Operating system: Linux
Graphics card: Intel

Blender Version
Broken:

  • 2.93
  • 2.92
  • 2.91.x
  • 2.83.x

Worked:

  • Never

Short description of error

Trying to register an operator class with bl_description = None causes a segfault.

bl_idname = None and bl_label = None both raise warnings instead of crashing. Also, there seems to be some equivalence/interchangeability for setting descriptions using __doc__ instead of bl_description— The default value of which is None. So I think it could be nice to handle this case gracefully.

Exact steps for others to reproduce the error

  • Define any operator class.
  • Set bl_description = None in that operator class's class attributes.
  • Try to register that operator class.

Example:

import bpy

class CrashOperator(bpy.types.Operator):
	bl_idname = "object.crash_operator"
	bl_label = "Crash Operator"
	bl_description = None

bpy.utils.register_class(CrashOperator)
**System Information** Operating system: Linux Graphics card: Intel **Blender Version** Broken: - 2.93 - 2.92 - 2.91.x - 2.83.x Worked: - Never **Short description of error** Trying to register an operator class with `bl_description = None` causes a segfault. `bl_idname = None` and `bl_label = None` both raise warnings instead of crashing. Also, there seems to be some equivalence/interchangeability for setting descriptions using `__doc__` instead of `bl_description`— The default value of which is `None`. So I think it could be nice to handle this case gracefully. **Exact steps for others to reproduce the error** * Define any operator class. * Set `bl_description = None` in that operator class's class attributes. * Try to register that operator class. Example: ``` import bpy class CrashOperator(bpy.types.Operator): bl_idname = "object.crash_operator" bl_label = "Crash Operator" bl_description = None bpy.utils.register_class(CrashOperator) ```
Author

Added subscriber: @WCN

Added subscriber: @WCN

Added subscriber: @rjg

Added subscriber: @rjg

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

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

I can confirm this crash.

BLI_strnlen(const unsigned char * s, const unsigned __int64 maxlen) Line 860	C
BLI_strncpy(unsigned char * dst, const unsigned char * src, const unsigned __int64 maxncpy) Line 110	C
rna_Operator_bl_description_set(PointerRNA * ptr, const unsigned char * value) Line 1802	C
Operator_bl_description_set(PointerRNA * ptr, const unsigned char * value) Line 697	C
RNA_property_string_set(PointerRNA * ptr, PropertyRNA * prop, const unsigned char * value) Line 3415	C
pyrna_py_to_prop(PointerRNA * ptr, PropertyRNA * prop, void * data, _object * value, const unsigned char * error_prefix) Line 1826	C
bpy_class_validate_recursive(PointerRNA * dummyptr, StructRNA * srna, void * py_data, int * have_function) Line 8355	C
bpy_class_validate(PointerRNA * dummyptr, void * py_data, int * have_function) Line 8369	C
rna_Operator_register(Main * bmain, ReportList * reports, void * data, const unsigned char * identifier, int(*)(PointerRNA *, void *, int *) validate, int(*)(bContext *, PointerRNA *, FunctionRNA *, ParameterList *) call, void(*)(void *) free) Line 1512	C
pyrna_register_class(_object * UNUSED_self, _object * py_class) Line 8888	C
I can confirm this crash. ```lines BLI_strnlen(const unsigned char * s, const unsigned __int64 maxlen) Line 860 C BLI_strncpy(unsigned char * dst, const unsigned char * src, const unsigned __int64 maxncpy) Line 110 C rna_Operator_bl_description_set(PointerRNA * ptr, const unsigned char * value) Line 1802 C Operator_bl_description_set(PointerRNA * ptr, const unsigned char * value) Line 697 C RNA_property_string_set(PointerRNA * ptr, PropertyRNA * prop, const unsigned char * value) Line 3415 C pyrna_py_to_prop(PointerRNA * ptr, PropertyRNA * prop, void * data, _object * value, const unsigned char * error_prefix) Line 1826 C bpy_class_validate_recursive(PointerRNA * dummyptr, StructRNA * srna, void * py_data, int * have_function) Line 8355 C bpy_class_validate(PointerRNA * dummyptr, void * py_data, int * have_function) Line 8369 C rna_Operator_register(Main * bmain, ReportList * reports, void * data, const unsigned char * identifier, int(*)(PointerRNA *, void *, int *) validate, int(*)(bContext *, PointerRNA *, FunctionRNA *, ParameterList *) call, void(*)(void *) free) Line 1512 C pyrna_register_class(_object * UNUSED_self, _object * py_class) Line 8888 C ```

In rna_wm.c, rna_def_operator(BlenderRNA *brna) it clears the PROP_NEVER_NULL flag. Either this needs to be changed to enforce that it is never null or the validation needs to be improved.

  prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
  RNA_def_property_string_sdna(prop, NULL, "type->description");
  RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
  /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
  RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
  RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
In `rna_wm.c`, `rna_def_operator(BlenderRNA *brna)` it clears the `PROP_NEVER_NULL` flag. Either this needs to be changed to enforce that it is never null or the validation needs to be improved. ``` prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->description"); RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set"); /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */ ```
Campbell Barton self-assigned this 2021-03-29 12:25:50 +02:00

This issue was referenced by e0ce76f1c5

This issue was referenced by e0ce76f1c5eb70ab66755dce4627b918fc102cbd

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
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
4 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#86983
No description provided.