Hovering over 'Search' operator in Add Menu of Node editor when using custom shortcut causes crash #44822

Closed
opened 2015-05-24 11:53:16 +02:00 by Greg Zaal · 8 comments
Member

System Information
Windows 7 64 bit
also tested Linux 64 bit

Blender Version
Broken: Current master (78250f1), also 2.72 (071ec91), don't have anything older than that

Short description of error
In the Add menu of the node editor is a Search button to search through all the node types - right click it and add a custom shortcut (e.g. Ctrl-A). Now hover over the button, when the tooltip should pop up, blender segfaults.

It doesn't crash if a custom shortcut is not set, and I couldn't reproduce this behaviour with any other button - hovering over other custom shortcuts of mine work just fine.

**System Information** Windows 7 64 bit also tested Linux 64 bit **Blender Version** Broken: Current master (78250f1), also 2.72 (071ec91), don't have anything older than that **Short description of error** In the Add menu of the node editor is a Search button to search through all the node types - right click it and add a custom shortcut (e.g. Ctrl-A). Now hover over the button, when the tooltip should pop up, blender segfaults. It doesn't crash if a custom shortcut is not set, and I couldn't reproduce this behaviour with any other button - hovering over other custom shortcuts of mine work just fine.
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @GregZaal

Added subscriber: @GregZaal

Added subscriber: @mont29

Added subscriber: @mont29
Bastien Montagne self-assigned this 2015-05-24 18:50:33 +02:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Campbell, need your help here, root of the issue is that bpy enum_itemf callback (bpy_prop_enum_itemf_cb()) assumes given context is never NULL, which is wrong!

Tried placing all calls involving context in that func behind checks (passing Py_None as context in this case), seems to work, but need your advice here before I commit!

P227: #44822

diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 779c738..a5da6e5 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -1481,15 +1481,26 @@ static EnumPropertyItem *bpy_prop_enum_itemf_cb(struct bContext *C, PointerRNA *
 	EnumPropertyItem *eitems = NULL;
 	int err = 0;
 
-	bpy_context_set(C, &gilstate);
+	if (C) {
+		bpy_context_set(C, &gilstate);
+	}
+	else {
+		gilstate = PyGILState_Ensure();
+	}
 
 	args = PyTuple_New(2);
 	self = pyrna_struct_as_instance(ptr);
 	PyTuple_SET_ITEM(args, 0, self);
 
 	/* now get the context */
-	PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module);
-	Py_INCREF(bpy_context_module);
+	if (C) {
+		PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module);
+		Py_INCREF(bpy_context_module);
+	}
+	else {
+		PyTuple_SET_ITEM(args, 1, Py_None);
+		Py_INCREF(Py_None);
+	}
 
 	items = PyObject_CallObject(py_func, args);
 
@@ -1530,8 +1541,13 @@ static EnumPropertyItem *bpy_prop_enum_itemf_cb(struct bContext *C, PointerRNA *
 		eitems = DummyRNA_NULL_items;
 	}
 
+	if (C) {
+		bpy_context_clear(C, &gilstate);
+	}
+	else {
+		PyGILState_Release(gilstate);
+	}
 
-	bpy_context_clear(C, &gilstate);
 	return eitems;
 }
 

Campbell, need your help here, root of the issue is that bpy enum_itemf callback (`bpy_prop_enum_itemf_cb()`) assumes given context is never NULL, which is wrong! Tried placing all calls involving context in that func behind checks (passing `Py_None` as context in this case), seems to work, but need your advice here before I commit! [P227: #44822](https://archive.blender.org/developer/P227.txt) ``` diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 779c738..a5da6e5 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1481,15 +1481,26 @@ static EnumPropertyItem *bpy_prop_enum_itemf_cb(struct bContext *C, PointerRNA * EnumPropertyItem *eitems = NULL; int err = 0; - bpy_context_set(C, &gilstate); + if (C) { + bpy_context_set(C, &gilstate); + } + else { + gilstate = PyGILState_Ensure(); + } args = PyTuple_New(2); self = pyrna_struct_as_instance(ptr); PyTuple_SET_ITEM(args, 0, self); /* now get the context */ - PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module); - Py_INCREF(bpy_context_module); + if (C) { + PyTuple_SET_ITEM(args, 1, (PyObject *)bpy_context_module); + Py_INCREF(bpy_context_module); + } + else { + PyTuple_SET_ITEM(args, 1, Py_None); + Py_INCREF(Py_None); + } items = PyObject_CallObject(py_func, args); @@ -1530,8 +1541,13 @@ static EnumPropertyItem *bpy_prop_enum_itemf_cb(struct bContext *C, PointerRNA * eitems = DummyRNA_NULL_items; } + if (C) { + bpy_context_clear(C, &gilstate); + } + else { + PyGILState_Release(gilstate); + } - bpy_context_clear(C, &gilstate); return eitems; } ```

@mont29, checked the patch and think this is the only viable option.

Note that NULL context is used generating docs too.

(node poll function will need update too of course)

@mont29, checked the patch and think this is the only viable option. Note that NULL context is used generating docs too. (node poll function will need update too of course)

This issue was referenced by a80c1e50bc

This issue was referenced by a80c1e50bc7f57bc4d4c41bc51ac92d1d4c39030

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' 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#44822
No description provided.